Add Constraint
suggest changeALTER TABLE Employees
ADD CONSTRAINT DefaultSalary DEFAULT ((100)) FOR [Salary]
This adds a constraint called DefaultSalary which specifies a default of 100 for the Salary column. The FOR clause is SQL Server syntax.
A constraint can be added at the table level.
Types of constraints
- Primary Key - prevents duplicate values in the key column or columns, and rejects NULL
- Foreign Key - points to a unique or primary key in another table
- Not Null - prevents null values from being entered into a column
- Unique - requires each non-NULL value in the column or columns to be unique (whether more than one NULL is allowed depends on the dialect)
- Default - specifies a default value
- Check - limits the range of values that can be placed in a column
To learn more about constraints, see the Oracle documentation.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents