|
From: Adriano d. S. F. <adr...@gm...> - 2009-11-23 09:56:44
|
Alexander Peshkoff escreveu: > Suppose mentioned NOT NULL field is used in FK. Suppose provided default value > violates RI. What is supposed engine reply to user? Raise error or not? It works automagically the way I think it should, raising an error: --------------- SQL> create table t1 (pk int primary key); SQL> insert into t1 values (1); SQL> insert into t1 values (2); SQL> insert into t1 values (3); SQL> commit; SQL> create table t2 (n int); SQL> insert into t2 values (0); SQL> insert into t2 values (-1); SQL> commit; SQL> alter table t2 add fk int default 4 not null references t1; Statement failed, SQLSTATE = 23000 violation of FOREIGN KEY constraint "INTEG_7" on table "T2" -Foreign key reference target does not exist SQL> alter table t2 add fk int default 3 not null references t1; SQL> --------------- Adriano |