ON DELETE CASCADE
: When you delete rows in the master table referenced by other tables, all those child tables will also delete their rows that reference the deleted master data.
ON UPDATE NO ACTION
: If you try to update a field in the master table referenced by others, MySQL will prevent you from doing that. NO ACTION
and RESTRICT
are synonyms in MySQL.
So to answer your updated question, MySQL will prevent you from updating a field in the master table that is referenced by any child tables because you specified NO ACTION
. If you are updating any other field in the master table it will take the same amount of time as an update on a table without foreign keys.
No, you can't depend on this. SQL is declarative, not procedural, so within a statement you can't guarantee the order of execution. Since the entire INSERT ALL
statement is considered a single statement (doc), you can't guarantee that one INSERT
will be before another.
By definition an INSERT FIRST
must execute the first INTO
passing the evaluated conditions. We might expect INSERT ALL
to behave similarly. This appears to be the case:
DROP TABLE T1;
CREATE TABLE T1 AS (SELECT 'a' c1, 0 c2, 0 c3 FROM dual WHERE 1=2);
INSERT ALL
WHEN mod(x,2)<>0 THEN INTO T1 VALUES ('a', x, mod(x,2))
WHEN mod(x,2)=0 THEN INTO T1 VALUES ('b', x, mod(x,2))
SELECT Level x FROM dual CONNECT BY Level <=20;
COMMIT;
SELECT rowid, c1, c2, c3 FROM t1;
However, even though we can demonstrate a particular behavior on a particular platform/version/patchset still doesn't make this a guarantee.
Oracle-developer.net says it explicitly:
the conditions in an INSERT FIRST statement will be evaluated in order
from top to bottom. Oracle makes no such guarantees with an INSERT ALL
statement.
Best Answer
The schema name of a table is not stored in the column
table_name
, it's stored in the columntable_schema
, so you need to change the condition:to