My Oracle administration notes/findings. You are welcome to browse and comment.

Thursday, October 1, 2009

Multi-table insert first

Example

user1@orcl92> select * from tt;

         X          Y Z
---------- ---------- --------------------
         1        100 aa
         2        200 bb
         3        300 cc
         4        400 dd


user1@orcl92> select * from tt1, tt2;

no rows selected

user1@orcl92> insert first
when x=3 then into tt1
when x>0 then into tt2
select * from tt;

4 rows created.

user1@orcl92> select * from tt1;

         X          Y Z
---------- ---------- --------------------
         3        300 cc

user1@orcl92> select * from tt2;

         X          Y Z
---------- ---------- --------------------
         1        100 aa
         2        200 bb
         4        400 dd   <-- No X=3 row.


The row with x=3 is missing from tt1 because it is excluded during the evaluation of the second "where" clause due to this row satisfying the first clause "x=3".

No comments:

Post a Comment

Followers