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 37 38 39 40 41 42 43 44 45 46 47 48
|
SQL> create table lsc_t(
2 entite_id_1 number,
3 entite_id_2 number,
4 entite_id_3 number,
5 constraint lsc_t_check1 check (entite_id_1 is not null or entite_id_3 is not null),
6 constraint lsc_t_check2 check (entite_id_2 is not null or entite_id_1 is not null)
7 );
Table created.
SQL> insert into lsc_t(entite_id_1,entite_id_2,entite_id_3) values (1,1,1);
1 row created.
SQL> insert into lsc_t(entite_id_1,entite_id_2) values (2,2);
1 row created.
SQL> insert into lsc_t(entite_id_1,entite_id_3) values (3,3);
1 row created.
SQL> insert into lsc_t(entite_id_2,entite_id_3) values (4,4);
1 row created.
SQL> insert into lsc_t(entite_id_1) values (5);
1 row created.
SQL> insert into lsc_t(entite_id_2) values (6);
insert into lsc_t(entite_id_2) values (6)
*
ERROR at line 1:
ORA-02290: check constraint (TGPOWNER.LSC_T_CHECK1) violated
SQL> insert into lsc_t(entite_id_3) values (7);
insert into lsc_t(entite_id_3) values (7)
*
ERROR at line 1:
ORA-02290: check constraint (TGPOWNER.LSC_T_CHECK2) violated
SQL> commit;
Commit complete. |
Partager