A constraint in SQL defines rules or restrictions that apply to data in a table, ensuring data integrity. Common constraints include:
- PRIMARY KEY: Ensures the values’ uniqueness in a column.
- FOREIGN KEY: Enforces referential integrity between tables.
- UNIQUE: Ensures the uniqueness of values in a column.
- CHECK: Defines a condition that data must meet to be inserted or updated.
- NOT NULL: Ensures that there are no NULL values in a column.
Leave a Reply