SQL ALTER TABLE Add Constraint

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!


ADD CONSTRAINT DefaultSalary DEFAULT ((100)) FOR [Salary]

This adds a constraint called DefaultSalary which specifies a default of 100 for the Salary column.

A constraint can be added at the table level.

Types of constraints

  • Primary Key - prevents a duplicate record in the table
  • Foreign Key - points to a primary key from another table
  • Not Null - prevents null values from being entered into a column
  • Unique - uniquely identifies each record in the table
  • Default - specifies a default value
  • Check - limits the ranges of values that can be placed in a column

To learn more about constraints, see the Oracle documentation.

Got any SQL Question?