SQLite Foreign Key Trigger Generator


This generator is a work in progress. The reason it exists is because SQLite parses fk column constraints but does not enforce them. You can read more about the problem and its solution if you are interested. The gist of it all is that triggers can be used in SQLite to enforce fk column constraints. However, generating the triggers can sometimes be a pain. This generator will parse out your column definitions in a CREATE TABLE statement and generate the SQL to create the triggers needed to enforce the fk column constraints.

Please not this has not been tested very much! Please report any bugs using the contact us form.

Supported ON UPDATE and ON DELETE actions

  • ON DELETE RESTRICT [default if not explicit]

Other actions can probably be implimented relatively easily if needed. Send and email through the contact us form if you have a feature request or bug report.

Enter your SQLite create statement (with constraint) below:


* indicates a required field


Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License.

Source Code

You can download a stand-alone implementation of this code. Note the license above. Also, if you make improvements to the generator, please send the code back to me and I will update my version and post it here for others to benefit from.

Lower Navigation (skip navigation)