-
-
Save dhilst/2f1955b50bcb2580a854294f1887d4e6 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_%' | |
AND 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