Postgres common tasks


Create user with password and grant roles to tables and sequences

Select database:

\c database_name

Create user with password:

create user someuser password 'somepassword';

Grant privileges on DB:

GRANT ALL PRIVILEGES ON DATABASE mydb TO someuser;

Grant privileges on all tables in particular DB:

GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO someuser;

Grant privileges on all sequences:

GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO someuser;