http://androidren.com/index.php?qa=298&qa_1=sqlite%E4%BB%8E%E4%BB%80%E4%B9%88%E7%89%88%E6%9C%AC%E5%BC%80% E5%a7%8b%e6%94%af%e6%8c%81%e5%a4%96%e9%94%ae-foreign-key
FOREIGN KEY constraints are supported starting from SQLite 3.6.19.
Reference:
Http://sqlite.org/foreignkeys.html
foreign key constraints is disabled by Default (for backwards compatibility), so must is enabled separately for each database connection. (Note, however, that the future releases of the SQLite might change so, foreign KEY constraints enabled by default.) Careful developers won't make any assumptions about whether or not foreign keys is enabled by default but would instead Enable or disable them as necessary.) The application can also use A pragma foreign_keys statement to determine if foreign keys is currently enabled. The following command-line session demonstrates this:
sqlite> PRAGMA foreign_keys;0sqlite> PRAGMA foreign_keys = on;sqlite> PRAGMA foreign_keys;1sqlite> PRAGMA Foreign_keys = off;sqlite> PRAGMA foreign_keys;0 |
Tip:if the command "PRAGMA foreign_keys" returns no data instead of a single row containing "0" or "1" and then the version of SQLite you were using does not foreign keys (either because it's older than 3.6.19 or because it was compiled W ith Sqlite_omit_foreign_key or sqlite_omit_triggerdefined).
It is not possible to enable or disable foreign key constraints in the middle of a multi-statement transaction (when Sqlit E is not in autocommit mode). Attempting to does so does not return an error; It simply has no effect.
What version of SQLite is starting to support foreign keys (Foreign key)