Skip to content

Instantly share code, notes, and snippets.

@jerinisready
Last active November 21, 2018 09:06
Show Gist options
  • Select an option

  • Save jerinisready/ff754db6ce33511c5010fc52677c5146 to your computer and use it in GitHub Desktop.

Select an option

Save jerinisready/ff754db6ce33511c5010fc52677c5146 to your computer and use it in GitHub Desktop.
Postgresql Quick Refer Collection. [Generate SQL's For Altering Ownership for all table] [psql: FATAL: role "user" is not permitted to log in]
# Generate SQLs For Altering Ownership for all table
SELECT 'ALTER TABLE '|| schemaname || '.' || tablename ||' OWNER TO ipc_user;'
FROM pg_tables WHERE NOT schemaname IN ('pg_catalog', 'information_schema')
ORDER BY schemaname, tablename;
# TO PERMIT LOGIN
# issue : 'psql: FATAL: role "user" is not permitted to log in'
CREATE ROLE "user" WITH PASSWORD 'password';
DROP DATABASE IF EXISTS "testdb"; CREATE DATABASE "testdb" OWNER "user";
# GRANT ALL ON DATABASE "testdb" TO "user"; ## !OWNERSHIP DO THE SAME
ALTER ROLE "user" WITH LOGIN;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment