Created
October 9, 2019 20:30
-
-
Save stefanthoss/d0125ac9687f9736b6bcb4e3eedee027 to your computer and use it in GitHub Desktop.
Find PostgreSQL tables that have columns which match a certain regex.
This file contains 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 | |
t.table_schema, | |
t.table_name, | |
c.column_name | |
FROM | |
information_schema.tables t | |
INNER JOIN information_schema.columns c ON c.table_name = t.table_name | |
AND c.table_schema = t.table_schema | |
WHERE | |
c.column_name ~ 'regex' | |
AND t.table_type = 'BASE TABLE' | |
ORDER BY | |
t.table_schema ASC, | |
t.table_name ASC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment