Created
January 8, 2014 20:38
-
-
Save geobabbler/8324190 to your computer and use it in GitHub Desktop.
List foreign keys in SQLite. http://stackoverflow.com/questions/5499003/sqlite-list-all-foreign-keys-in-a-database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT sql | |
FROM ( | |
SELECT sql sql, type type, tbl_name tbl_name, name name | |
FROM sqlite_master | |
UNION ALL | |
SELECT sql, type, tbl_name, name | |
FROM sqlite_temp_master | |
) | |
WHERE type != 'meta' | |
AND sql NOTNULL | |
AND name NOT LIKE 'sqlite_%' | |
ANE sql LIKE '%REFERENCES%' | |
ORDER BY substr(type, 2, 1), name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI:
ANE sql LIKE '%REFERENCES%'
should beAND sql LIKE '%REFERENCES%'