You're right. "NO ACTION" means nothing has been done to maintain the integrity of foreign key constraints. For more information on the options you can set, see the documentation .
In this scenario, you can install 4 more options. RESTRICT, SET NULL, SET DEFAULT and CASCADE. A brief description of what they do:
RESTRICT . A row in the MASTER table can only be deleted if it does not refer to any rows in the SERVANT table.
SET NULL Deleting a row in the MASTER table will cause all FKs in the SERVANT table to be set to NULL.
INSTALL DEFAULT . Like the NULL set, except that FK is set to the default value instead of NULL.
CASCADE . Deleting a row in the MASTER table will cause any rows in the SERVANT table to refer to the deleted MASTER row, which will also be deleted.
To change these settings, you will need to change your create statements to indicate the update and deletion actions.
CREATE TABLE MASTER ( _ID INTEGER PRIMARY KEY, ... ); CREATE TABLE SERVANT ( _ID INTEGER PRIMARY KEY, MASTERID INTEGER, FOREIGN KEY(MASTERID) REFERENCES MASTER(_ID) ON UPDATE CASCADE ON DELETE SET NULL );
edit : Remember to make sure that your version of SQLite has been compiled with foreign key support and that you have enabled it by PRAGMA foreign_keys = ON;
source share