Constraints
1. Check Constraints
2. Default Constraints
3. primary key constraint (composite primary key, with multiple columns determining uniqueness)
4. Foreign key constraints
5. unique constraint (unique constraint)
The foreign key constraint is used to enhance the connection between two tables, such as adding, deleting, and modifying (dependencies between two tables)
Primary key constraints and unique constraints
1. Identify the unique data
2. Multiple columns are supported to determine uniqueness.
Differences between primary key constraints and unique constraints
1. The primary key cannot be blank. The unique constraint can be blank.
2. There is only one primary key, and the unique constraint can have multiple
---------------------------------------------------------------
Default
It seems that onlyCodeCreation Method
-- Create default
Create default gender as 'male'
-- Bind to column by default
Exec sp_bindefault gender, 'Teacher. Sex'
Commonalities of default and default Constraints
1. All provide column default values
Differences between default and default Constraints
1. By default, it seems that only code can be created.
2. The database object is used by default. It is created once and used in multiple tables.
---------------------------------------------------------------
Rules
-- Create a rule
Create rule price range: As @ price> 10 and @ price <100
-- Use rules
Exec sp_bindrule price range, 'class. price'
Similar to the default rule, the rule is a database object and can be bound to multiple tables at a time.