SQL Constraints

First: Introduction to Restrictions

Introduction to SQL Constraints:

What are the limitations of SQL?

The need for SQL constraints

SQL Create Constraints:

Second: Statements Of SQL Constraints

1- SQL NOT NULL Constraint:

Syntax of Add NOT NULL constraint With CREATE TABLE Statement in SQL
Syntax of Add NOT NULL constraint With ALTER TABLE Statement in SQL

2- SQL UNIQUE Constraint:

Write unique restriction after the name and type data of field
Write the UNIQUE constraint at the end of the CREATE TABLE statement
Add unique restriction to multiple fields
ADD UNIQUE with MODIFY Statement
Add UNIQUE Constraint With ADD COLUMN Statement
Add UNIQUE Constraint to multiple fields
Syntax of Delete UNIQUE constraint From Table in SQL

3- SQL PRIMARY KEY Constraint:

Add PRIMARY KEY Constraint after the name and type data of field
Add the PRIMARY KEY constraint at the end of the CREATE TABLE statement
Add PRIMARY Constraint to multiple fields
ADD UNIQUE with MODIFY Statement
Add PRIMARY KEY Constraint With ADD COLUMN Statement
Add PRIMARY KEY Constraint With ADD COLUMN Statement
Syntax of Delete PRIMARY KEY constraint From Table in SQL

4- SQL FOREIGN KEY Constraint:

Add FOREIGN KEY Constraint after the name and type data of field
Add the FOREIGN KEY constraint at the end of the CREATE TABLE statemen
Add FOREIGN KEY Constraint to multiple fields
ADD FOREIGN KEY with MODIFY Statement
Add FOREIGN KEY Constraint With ADD COLUMN Statement
Add FOREIGN KEY Constraint to multiple fields
Syntax of Delete FOREIGN KEY constraint From Table in SQL

5- SQL CHECK Constraint:

Add CHECK Constraint after the name and type data of field
Add the CHECK constraint at the end of the CREATE TABLE statement
Add CHECK Constraint to multiple fields
ADD CHECK with MODIFY Statement
Add CHECK Constraint With ADD COLUMN Statement
Add CHECK Constraint to multiple fields
Syntax of Delete CHECK constraint From Table in SQL

6- SQL DEFAULT Constraint:

Syntax of Add DEFAULT constraint With CREATE TABLE Statement in SQL
The DEFAULT constraint can also be used to insert system values, by using functions like GETDATE()
Syntax of Add DEFAULT constraint With ALTER TABLE Statement in SQL

7- SQL AUTO INCREMENT Constraints:

Syntax of Add AUTO_INCREMENT constraint With CREATE TABLE Statement in SQL
للسماح AUTO_INCREMENTللتسلسل بالبدء بقيمة أخرى ، استخدم عبارة SQL التالية:

مستودعي كل الأشياء التي تحتاج لمعرفتها حول SQL: تعلم SQL

Logo

华为、百度、京东云现已入驻,来创建你的专属开发者社区吧!

更多推荐