Objects
Syntax
<columnName> OBJECT
[ ({DYNAMIC|STRICT|IGNORED}) ]
[ AS ( <columnDefinition>* ) ]Example
CREATE TABLE my_table (
title TEXT,
quotation OBJECT,
protagonist OBJECT(STRICT) AS (
age INTEGER,
first_name TEXT,
details OBJECT AS (
birthday TIMESTAMP WITH TIME ZONE
)
)
);
INSERT INTO my_table (
title,
quotation,
protagonist
) VALUES (
'Alice in Wonderland',
{
"words" = 'Curiouser and curiouser!',
"length" = 3
},
{
"age" = '10',
"first_name" = 'Alice',
"details" = {
"birthday" = '1852-05-04T00:00Z'::TIMESTAMPTZ
}
}
);
SELECT
protagonist['first_name'] AS name,
date_format('%D %b %Y', 'GMT', protagonist['details']['birthday']) AS born,
protagonist['age'] AS age
FROM my_table;Object Column Policies
STRICT
DYNAMIC (Default)
IGNORED
Object Literals
Syntax:
Examples:
Inserting Objects as JSON Strings
Examples:
Last updated

