0% found this document useful (0 votes)
4 views1 page

43. Lec 51 SQL Practice

The document outlines the use of default constraints in SQL to provide default values for table columns. It includes two cases: creating a new table with default values and altering an existing table to add a default value for a column. The document also demonstrates inserting records into the table with and without specifying all column values, showcasing how defaults are applied.

Uploaded by

koulibalyhamam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

43. Lec 51 SQL Practice

The document outlines the use of default constraints in SQL to provide default values for table columns. It includes two cases: creating a new table with default values and altering an existing table to add a default value for a column. The document also demonstrates inserting records into the table with and without specifying all column values, showcasing how defaults are applied.

Uploaded by

koulibalyhamam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

--Default Constraint

--This constraint to provide default values to columns

--Case 1 : The table does not exist


create table test_default (
EID int default 5,
firstname varchar(256) default 'Rohit',
lastname varchar(256),
age tinyint
)

select * from test_default

insert into test_default values(1,'Nitin','Jain',23)

insert into test_default(lastname,age) values('Singh',34)

insert into test_default (lastname) values ('Grover')

--Case 2 : The table already exists

alter table test_default


add default 25 for age

insert into test_default (lastname) values('Jain')

select * from test_default

You might also like