SQL - Structured Query Language

Default Constraint



Default Constraint can define with a default literal Number, String, Date, UID or SQL Function Data in the mandatory column in the Table of Relational Database. Default Data must be match with Data Type and Range of the mandatory column or must be convert the Data Type and then store data in the mandatory column.
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