Скачать в pdf «PostgreSQL»


The CHECK constraint specifies a restriction on allowed values within a column. The CHECK constraint is also allowed as a table constraint.

The SQL92 CHECK column constraints can only be defined on, and refer to, one column of the table. Postgres does not have this restriction.

primary key Constraint

[ constraint name ] PRIMARY KEY


CONSTRAINT name An arbitrary name for the constraint.


ERROR: Cannot insert a duplicate key into a unique index. This occurs at runtime if one tries to insert a duplicate value into a column subject to a PRIMARY KEY constraint.


The PRIMARY KEY column constraint specifies that a column of a table may contain only unique (non-duplicate), non-NULL values. The definition of the specified column does not have to include an explicit NOT NULL constraint to be included in a PRIMARY KEY constraint.

Only one PRIMARY KEY can be specified for a table.


Postgres automatically creates a unique index to assure data integrity (see CREATE INDEX statement).

The PRIMARY KEY constraint should name a set of columns that is different from other sets of columns named by any UNIQUE constraint defined for the same table, since it will result in duplication of equivalent indexes and unproductive additional runtime overhead. However, Postgres does not specifically disallow this.


[ CONSTRAINT name ] REFERENCES reftable [ ( refcalumn ) ] [ MATCH matehtype ] [ ON DELETE action ] [ ON UPDATE action ] [ [ NOT ] DEFERRABLE ] [ INITIALLY checktime ] The REFERENCES constraint specifies a rule that a column value is checked against the values of another column. REFERENCES can also be specified as part of a FOREIGN KEY table constraint.

Скачать в pdf «PostgreSQL»