MAP(K, V)
stores key-value pairs. Here’s what K
and V
represent:
K
: The type of the Map keys. It can be string or integral types (i.e.,character varying
,smallint
,integer
, orbigint
). It must not beNULL
, and must be unique in the map.V
: The type of the Map values. It can be arbitrary type.
Define a map
To create a map withVARCHAR
keys and INTEGER
values, use the statement below.
map_from_key_values
or from an array of key-value pairs with map_from_entries
.
x
that has a MAP(VARCHAR, INTEGER)
column.
Access data in a map
Use bracket notation to access the value of a key.Modify data in a map
Usemap_insert
to insert or overwrite a key-value pair into a map.