SQL - Structured Query Language

Check Constraint



Check Constraint can define with a Logical Expression that used to valid data when Insert or Update Data in a Table of Relational Database.

The following SQL Statements are used to create DEPT and EMP Tables with set of constraints.

-- Sample Statements --

 

CREATE TABLE DEPT

(

Dept_Code numeric(5) Primary Key,

Dept_Name varchar(50) Not Null,

)

GO

 

CREATE TABLE EMP

(

Emp_Code numeric(5)Primary Key,

Emp_Name varchar(50) Not Null,

DOJ datetime Default GetDate(),

Salary numeric(7,2) Check (salary > 1000 and Salary < 5000),

Phone varchar(50),

Dept_Code numeric(5) References DEPT(Dept_Code)

On Delete Cascade

)

GO


More Reference URL: https://data-e-education.com/RDBMS/Domain_Integrity_Constraints.php

* * * * *


Email Your Comment To AUTHOR