android - What exactly does SQLite's "NO ACTION" foreign key constraint do and how is it different from "RESTRICT"? -


the documentation says:

configuring "no action" means that: when parent key modified or deleted database, no special action taken.

my first interpretation of sentence "if parent key modified or deleted, modification done , no other action taken" not preserving database integrity, lead confusion. testing showed, if try delete parent key (if child key still exists), exception ("sqliteconstraintexception: error code 19: constraint failed" - testing under android 4.0.3 / sqlite 3.7.x), "no action" seems behave expected.

could please explain , perhaps give example, "no action" , how different "restrict".

the introducing paragraph says:

if action not explicitly specified, defaults "no action".

this is normal action.

furthermore:

the difference between effect of restrict action , normal foreign key constraint enforcement restrict action processing happens field updated - not @ end of current statement immediate constraint, or @ end of current transaction deferred constraint.

if you're testing single-statement transaction changes 1 record, not see difference between no action , restrict.


Comments