Database Reference
In-Depth Information
(1 rows)
Maps
Maps are represented as JSON objects. They do not support duplicate keys but you can
have duplicate values. If you insert two or more entries with the same key, only one of
them will persist.
{'key1': value1, 'key2': value2, …}
You can add values using a key or appending another map. You can delete values by key
or by another map.
# Create a table and insert a map with duplicate keys
CREATE TABLE map_demo (id int PRIMARY KEY, map_col map<int,
text> );
INSERT INTO map_demo (id, map_col ) VALUES ( 1, {1:'one',
2: 'two', 1: 'dupe'} );
SELECT * FROM map_demo;
id | map_col
----+----------------------
1 | {1: 'one', 2: 'two'}
(1 rows)
# Update the value of a key
UPDATE map_demo SET map_col[3] = 'three' WHERE id = 1;
SELECT * FROM map_demo;
id | map_col
Search WWH ::




Custom Search