Search Postgresql Archives

jsonb unique constraints

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Can you have unique constraints on jsonb columns keys? I've looked for examples but haven't found any what is the proper syntax? Here's what I tried:

CREATE TABLE report_json (
    recnum int,
    id integer,
    report jsonb,
    PRIMARY KEY (recnum),
    CONSTRAINT report_json_unique_constraint UNIQUE (id,((report ->> 'data')::int),((report ->> 'ctc')::int),((report ->> 'dtg')::int)
);

which causes a syntax error at the first '(' around 'report ->>'.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux