PostgreSQL Conditionals Control Structures syntax: if then else, case when, return, exit, loop. Syntax IF expression THEN statement END IF; IF expression THEN statement_1 ELSE statement_2 END IF; IF expression_1 THEN statement_1 ELSIF expression_2 THEN statement_2 ELSE statement_3 END IF; CASE...
Add foreign key constraint to table How to add foreign key constraint to an existing table. Constraint syntax and example. Syntax ALTER TABLE table_name1 ADD CONSTRAINT fk_name FOREIGN KEY (column_name) REFERENCES table_name2 (unique_column_name); Example ALTER TABLE customers ADD CONSTRAINT fk_address FOREIGN...
Add unique key constraint to table How to add unique key constraint to an existing table. Constraint syntax and example. Syntax ALTER TABLE table_name ADD CONSTRAINT key_name UNIQUE (column_name); Example ALTER TABLE users ADD CONSTRAINT uk_mail UNIQUE (usermail);...