SQL Constraints
Table constraints — PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK, DEFAULT. This category documents 23 SQL constraints entries, and each page gives you the full syntax, the parameter list, the return value, and a runnable example tested against MySQL, PostgreSQL, SQL Server, and SQLite. The entries are: PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK, DEFAULT, EXCLUDE CONSTRAINT, PRIMARY KEY (Composite), FOREIGN KEY ON DELETE SET NULL, FOREIGN KEY ON UPDATE CASCADE, DEFERRABLE CONSTRAINT, WITH NOCHECK, ON DELETE NO ACTION, ON DELETE SET DEFAULT, ENABLE / DISABLE CONSTRAINT, UNIQUE NULL Behavior, Constraint Naming Conventions, CHECK Constraint with UDF, NOT FOR REPLICATION, ON DELETE RESTRICT, CHECK with Boolean Expression, DEFAULT with Function, SQL UNIQUE Constraint on Multiple Columns. Not sure where to start? PRIMARY KEY and FOREIGN KEY are the most commonly used entries in this category. You can also search across every category from the search page, browse the complete A–Z index, or try any of these statements live in the SQL playground.