Oracle PL/SQL/Constraints/Add Check Constraint — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 13:01, 26 мая 2010
Add another check constraint
<source lang="sql">
SQL> -- add a check constraint SQL> SQL> create table myTable (
2 a number check (a between 0 and 100), 3 b number 4 );
Table created. SQL> SQL> SQL> alter table myTable
2 add constraint ch_b check (b > 50);
Table altered. SQL> SQL> SQL> SQL> insert into myTable values(1, 30); insert into myTable values(1, 30)
ERROR at line 1: ORA-02290: check constraint (SYS.CH_B) violated
SQL> insert into myTable values(2000, 300); insert into myTable values(2000, 300)
ERROR at line 1: ORA-02290: check constraint (SYS.SYS_C004428) violated
SQL> insert into myTable values(2, 3000); 1 row created. SQL> SQL> select * from myTable;
A B
----------
2 3000
SQL> SQL> drop table myTable; Table dropped. SQL> SQL>
</source>