Professional Documents
Culture Documents
SQL 14
SQL 14
column level:
in this we are defining constarints in
individual columns
syntax:
create table tablename(col1 datatype(size) constraint,
col2 datatype(size) constraint name.......
table level:
in this we are defining constraints on group
of columns
syntax:
create table tablename(col1 datatype(size),
col2 datatype(size),...constrainttype(col1,col2..);
not null:
in all databases not null doesnot support table
level
not null doesnot accepts null values but it
accepts duplicates
column level:
SQL> create table test(sno number(10) not null,name varchar2(10));
Table created.
1 row created.
unique:
in all databases unique constraint defined both
column,table level
unique doesnot accepts duplicates and it accepts
null values
column level:
1 row created.
tabel level:
Table created.
1 row created.
SNO NAME
---------- ----------
1 a
1 row created.
SNO NAME
---------- ----------
1 a
2 b
1 row created.
SNO NAME
---------- ----------
1 a
2 b
1 b
note:
when ever we are primary key then oracle server
automatically creates btree index
column level:
syntax:
create table tablename(col1 datatype(size) primary
key,col2 datatype(size),.......);
Table created.
1 row created.
table level:
syntax:
create table tablename(col1 datatype(size),col2
datatype(size),...primary key(col1,col2...);
Table created.
1 row created.
SNO NAME
---------- ----------
1 a
SNO NAME
---------- ----------
1 a
1 b
unique/not null:
not null-null values not allowing,duplicate allow
unique-dupl not allow,null values allow
primary key:
both null,duplcates not allow