Specify CONSTRAINT : CONSTRAINT « Constraints « PostgreSQL






Specify CONSTRAINT


postgres=#
postgres=# CREATE TABLE products (
postgres(#    product_no integer,
postgres(#    name text,
postgres(#    price numeric,
postgres(#    CHECK (price > 0),
postgres(#    discounted_price numeric,
postgres(#    CHECK (discounted_price > 0),
postgres(#    CONSTRAINT valid_discount CHECK (price > discounted_price)
postgres(# );
CREATE TABLE
postgres=#
postgres=# drop table products;
DROP TABLE
postgres=#
           
       








Related examples in the same category