Sunday, 9 October 2011

SQL Constraints- Default

nThe DEFAULT constraint is used to insert a default value into a column.
nThe default value will be added to all new records, if no other value is specified.
Create-Default
CREATE TABLE EMPtbl1 (EMPID int, EMPname varchar(255),
company varchar(255), salary varchar(255),
Location varchar(255) DEFAULT ‘Bangalore' )
Alter-Default
ALTER TABLE EMPtbl1 ALTER COLUMN Location SET DEFAULT ‘Bangalore‘
Drop-Check
ALTER TABLE EMPtbl1
ALTER COLUMN Location DROP DEFAULT

1 comment: