Attach a foreign key or check constraint after table creation.
Section: CREATE, ALTER, and DROP
Add a constraint
sql
sql
ALTER TABLE orders
ADD CONSTRAINT fk_orders_customer
FOREIGN KEY (customer_id) REFERENCES customers(customer_id);Explanation
Constraints help maintain relational integrity.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing CREATE, ALTER, and DROP