create unique constraint on jsonb->filed during create table - Mailing list pgsql-general

From Andy Fan
Subject create unique constraint on jsonb->filed during create table
Date
Msg-id CAKU4AWpKK2FCWUXXwFsjnVhfta6mSWWFQ9_rteZ_c3Y3vTcEcg@mail.gmail.com
Whole thread Raw
Responses Re: create unique constraint on jsonb->filed during create table
List pgsql-general

The following way works with 2 commands:

zhifan=# create table t1 (a jsonb);
CREATE TABLE
zhifan=# create unique index t1_a_name on t1 ((a->'name'));
CREATE INDEX

but know I want to merge them into 1 command, is it possible?

zhifan=# create table t2 (a jsonb, constraint uk_t2_a_name unique((a->'name')));
ERROR:  syntax error at or near "("
LINE 1: ...table t2 (a jsonb, constraint uk_t2_a_name unique((a->'name'...

pgsql-general by date:

Previous
From: Michael Paquier
Date:
Subject: Re: cannot execute VACUUM during recovery
Next
From: "David G. Johnston"
Date:
Subject: Re: create unique constraint on jsonb->filed during create table