Hi all,

I've been implementing foreign keys in some of my older tables, as detailed at:
http://www.sqlite.org/foreignkeys.html

usually like this:

foreign key ChildTable (ChildColumn1, ChildColumn2)
        references ParentTable (ParentColumn1, ParentColumn2)
                on delete cascade

which is working well.

In some cases (eg for in table that logs changes), while I want to specify a 
foreign key relationship, I don't want deletions in the parent to cascade into 
the child or restrict the deletion. I notice that there is a "no action" 
option, so I've started to use that:

foreign key ChildTable (ChildColumn1, ChildColumn2)
        references ParentTable (ParentColumn1, ParentColumn2)
                on delete no action

I have a few questions:

1. What does SQLite do if the action is just left blank? Does it have the same 
affect as explicitly writing "no action"? ie is the above the same as:

foreign key ChildTable (ChildColumn1, ChildColumn2)
        references ParentTable (ParentColumn1, ParentColumn2)

2. I modified the schema to include "no action" on an app on my iPad (running 
SQLite version 3.6.23.2). But when I move it to my Mac (running SQLite version 
3.6.12) and then run:

pragma integrity_check;

I get an error:

SQL error: malformed database schema (ChildTable) - near "no": syntax error

Is this to be expected? I know that foreign key actions are supported in SQLite 
version 3.6.19 onward, but previous version supported parsing the foreign key 
schema. Did it not support parsing "no action"?

3. For backwards parsing compatibility, am I better off just leaving the action 
blank instead of explicitly writing "on delete no action"?

Thanks,
Tom
BareFeetWare

 --
Comparison of SQLite GUI tools:
http://www.barefeetware.com/sqlite/compare/?ml

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to