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

Not Null

The document outlines the creation of a SQL table named 'stu1' with various constraints, including a primary key and a check for minimum marks. An attempt to insert a record with a NULL name fails due to the NOT NULL constraint, while a subsequent successful insertion includes valid data. The final query retrieves and displays the inserted record from the table.

Uploaded by

musicsri12
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)
2 views1 page

Not Null

The document outlines the creation of a SQL table named 'stu1' with various constraints, including a primary key and a check for minimum marks. An attempt to insert a record with a NULL name fails due to the NOT NULL constraint, while a subsequent successful insertion includes valid data. The final query retrieves and displays the inserted record from the table.

Uploaded by

musicsri12
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

CONSTRAINTS

SQL> create table stu1(regno varchar(9),


2 name char(9) not null,
3 eno number(2) unique,
4 dep char(2) default 'it',
5 mark number(9) check (mark>=40),
6 constraint pk primary key (regno));

Table created.

SQL> insert into stu1 values(&regno,&name,&eno,&dep,&mark);


Enter value for regno: '01'
Enter value for name: ''
Enter value for eno: 001
Enter value for dep: 'cs'
Enter value for mark: 50
old 1: insert into stu1 values(&regno,&name,&eno,&dep,&mark)
new 1: insert into stu1 values('01','',001,'cs',50)
insert into stu1 values('01','',001,'cs',50)
*
ERROR at line 1:
ORA-01400: cannot insert NULL into ("SYSTEM"."STU1"."NAME")

SQL> insert into stu1 values(&regno,&name,&eno,&dep,&mark);


Enter value for regno: '01'
Enter value for name: 'ashok'
Enter value for eno: 001
Enter value for dep: 'cs'
Enter value for mark: 50
old 1: insert into stu1 values(&regno,&name,&eno,&dep,&mark)
new 1: insert into stu1 values('01','ashok',001,'cs',50)

1 row created.

SQL> select * from stu1;

REGNO NAME ENO DE MARK


--------- --------- ---------- -- ----------
01 ashok 1 cs 50

You might also like