constraint
PRIMARY KEY
Identifies each row uniquely and disallows NULL in PostgreSQL. Composite keys identify rows by a tuple. SQLite ordinary rowid tables have historical NULL exceptions; INTEGER PRIMARY KEY also generates a key when NULL is inserted. Target: PostgreSQL 17; focused syntax.
Formal Syntax & Structure
sql syntaxsql
PRIMARY KEY (id)Working Example
Example Snippetsql
CREATE TABLE t(id INT PRIMARY KEY NOT NULL);INSERT INTO t VALUES (1);INSERT INTO t VALUES (1);