1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| create table tab
(
c1 integer,
c2 integer,
constraint chk_addition
check (c1 + c2 >= 10)
);
-- Table created.
insert into tab (c1, c2) values (5, 8);
-- 1 row created.
insert into tab (c1, c2) values (5, 2);
-- ORA-02290: violation de contraintes (CHK_ADDITION) de vérification
commit;
--Commit complete.
select constraint_name, constraint_type, table_name, search_condition
from ALL_CONSTRAINTS
where owner = user
and constraint_name = 'CHK_ADDITION';
CONSTRAINT_NAME CONSTRAINT_TYPE TABLE_NAME SEARCH_CONDITION
--------------- --------------- --------------- ----------------
CHK_ADDITION C TAB c1 + c2 >= 10
select constraint_name, table_name, column_name
from ALL_CONS_COLUMNS
where owner = user
and constraint_name = 'CHK_ADDITION';
CONSTRAINT_NAME TABLE_NAME COLUMN_NAME
--------------- --------------- ---------------
CHK_ADDITION TAB C1
CHK_ADDITION TAB C2 |
Partager