SQL Default Constraints


Prev Tutorial Next Tutorial

SQL Default Constraints

Default Constraints is used to insert a default value into a column. The default value will be added to all new records, if no other value is specified.

My SQL or SQL Server or Oracle or MS Access

	
create table Employee
(
e_id number(3) NOT NULL,,
e_name varchar(15),
sal number(5),
City varchar(255) DEFAULT 'Delhi',
);

In above syntax in city column by default value for city of every employee is delhi.

SQL DEFAULT Constraint on Alter Table

My SQL

	
ALTER TABLE Employee
ALTER City SET DEFAULT 'delhi'

SQL Server or MS Access

	
ALTER TABLE Employee
ALTER COLUMN City SET DEFAULT 'delhi'

Oracle

	
ALTER TABLE Employee
ALTER City SET DEFAULT 'delhi'

Drop Default Constraints

My SQL

	
ALTER TABLE Employee
ALTER City DROP DEFAULT

SQL Server or Oracle or MS Access

	
ALTER TABLE Employee
ALTER COLUMN City DROP DEFAULT

Prev Tutorial Next Tutorial

Advertisements




Facebook Likes

Advertisements