Creating Tables With SQL-92 Constraints

Most commercial systems have adopted the SQL-92 CREATE TABLE options for PRIMARY KEY, UNIQUE, DEFAULT, CHECK, REFERENCES, and FOREIGN KEY. These elements provide important data integrity protections. A column-level constraint applies to a single column (for example, au_id). A table-level constraint applies to multiple columns (perhaps the combination of au_lname and au_fname)—not to the whole table.

  • PRIMARY KEY marks the column (which cannot allow NULLs) as the primary key of the table. Every value entered must be unique, or the input is rejected. The handling of this constraint internally varies from system to system, but it is often equivalent to a unique index.

  • UNIQUE also guarantees the distinctness ...

Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.