AdBlock Detected!
Our website is made possible by displaying ads to our visitors. Please supporting us by whitelisting our website.
SQL Add Constraint Syntax |
|
SQL > ALTER TABLE >
Add Constraint Syntax
Sometimes we may decide to add a new constraint to an existing table (to see what are the different types of constraints that can be placed on a database table, please refer to the CONSTRAINT section). The ALTER TABLE ADD CONSTRAINT statement allows you to enforce data integrity rules — such as UNIQUE, PRIMARY KEY, or FOREIGN KEY — on an existing table without recreating it.
The syntax for adding a constraint in SQL is, Let's look at the example. Assuming our starting point is the Customer table created in the CREATE TABLE section: Table Customer
Assume we want to add a UNIQUE constraint to the "Address" column. To do this, we type in the following: MySQL:
Oracle:
SQL Server:
where Con_First is the name of the constraint. Frequently Asked Questions
|
Our website is made possible by displaying ads to our visitors. Please supporting us by whitelisting our website.