Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 00krishna/c163f5675dfb06fa74dc20fceb16d4fa to your computer and use it in GitHub Desktop.
Save 00krishna/c163f5675dfb06fa74dc20fceb16d4fa to your computer and use it in GitHub Desktop.
-- lower case table names -- the psql friendly and more reader-friendly way
SELECT 'ALTER TABLE ' || quote_ident(t.table_schema) || '.'
|| quote_ident(t.table_name) || ' RENAME TO ' || quote_ident(lower(t.table_name)) || ';' As ddlsql
FROM information_schema.tables As t
WHERE t.table_schema NOT IN('information_schema', 'pg_catalog')
AND t.table_name <> lower(t.table_name)
ORDER BY t.table_schema, t.table_name;
--generates something like this
--ALTER TABLE public."SPRINT" RENAME TO sprint;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment