Check
create table employee(eid number primary key , ename
varchar2(30), city varchar2(30),salary number);
0.07 seconds
insert into employee values(1,'ram','kol',20000);
insert into employee values(2,'sam','goa',30000);
insert into employee values(3,'jam','delhi',40000);
create table employee2(eid number , ename varchar2(30) check (ename like
's%'));
Table created
insert into employee2 values(1,'sam');
1 row(s) inserted.
insert into employee2 values(1,'ram');
ORA-02290: check constraint (SYS.SYS_C003999) violated
create table employee3(eid
number , ename varchar2(30), city
varchar2(30) check(city in('kol','goa'))
);
Table created.
0.68 seconds |
insert
into employee3 values(1,'ram','kol');
1 row(s) inserted.
0.07 seconds
insert
into employee3 values(2,'sam','delhi');
ORA-02290: check constraint
(SYS.SYS_C004000) violated
create table employee1(eid number
primary key , ename varchar2(30) check (ename like 's%'), city varchar2(30)
check(city in('kol','goa')),salary number check(salary>20000));
insert into employee1
values(1,'jam','delhi',40000);
ORA-02290: check constraint (SYS.SYS_C003996) violated
|
No comments:
Post a Comment