Assign your own name for a unique constraint : Unique « Constraints « PostgreSQL






Assign your own name for a unique constraint


postgres=# -- Assign your own name for a unique constraint
postgres=#
postgres=# CREATE TABLE products (
postgres(#    product_no integer CONSTRAINT must_be_different UNIQUE,
postgres(#    name text,
postgres(#    price numeric
postgres(# );
NOTICE:  CREATE TABLE / UNIQUE will create implicit index "must_be_different" for table "products"
CREATE TABLE
postgres=#
postgres=#
postgres=# drop table products;
DROP TABLE
postgres=#
postgres=#
           
       








Related examples in the same category

1.Unique Constraints
2.Specifying the unique column using Unique function
3.Unique constraint refers to a group of columns, the columns are listed separated by commas
4.Unique and not null column