Last active
August 29, 2015 14:22
-
-
Save johannesberdin/351ce3f027b9e619c5f5 to your computer and use it in GitHub Desktop.
Generates ALTER TABLE queries for lowercased column names and table names
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
/* Lowercases column names */ | |
SELECT 'ALTER TABLE ' || quote_ident(c.table_schema) || '.' || quote_ident(c.table_name) || ' RENAME ' || quote_ident(c.column_name) || ' TO ' || quote_ident(lower(c.column_name)) || ';' As ddlsql FROM information_schema.columns As c WHERE c.table_schema NOT IN('information_schema', 'pg_catalog') AND c.column_name <> lower(c.column_name) ORDER BY c.table_schema, c.table_name, c.column_name; | |
/* Lowercases table names */ | |
SELECT 'ALTER TABLE ' || quote_ident(c.table_schema) || '.' || quote_ident(c.table_name) || ' RENAME TO ' || quote_ident(lower(c.table_name)) || ';' As ddlsql FROM information_schema.tables As c WHERE c.table_schema NOT IN('information_schema', 'pg_catalog') AND c.table_name <> lower(c.table_name) ORDER BY c.table_schema, c.table_name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment