Last active
February 13, 2024 11:44
-
-
Save barryparkin/9089296 to your computer and use it in GitHub Desktop.
(sqlite) Find table in database by field name
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 DISTINCT TABLE_NAME | |
FROM INFORMATION_SCHEMA.COLUMNS | |
WHERE COLUMN_NAME like '%{{fieldname}}%' | |
AND TABLE_SCHEMA = {{Database}}; |
WHERE sql like
can you explain the sql here? it's not any field name right?
Only fieldname has to be included
I just realised sqlite_master is a special table where sql is the last column with the CREATE statement text. Thanks !!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my case sqlite_master instead of INFORMATION_SCHEMA was available for sqlite3:
SELECT DISTINCT name FROM sqlite_master
WHERE sql like '%fieldname%';