Postgresql setup/commands

Config file path [pg_hba.conf]:  

Centos:  /var/lib/pgsql/data/

Ubuntu:  /etc/postgresql/

List databases:  \l or \list

List of roles:  \du

Create roles:  CREATE ROLE role-name;

Create role with permissions:  CREATE ROLE role-name WITH optional_permissions;

Change permissions after role is created:  ALTER ROLE role-name WITH options;

See all options:  \h

See all options for a particular function:  \h FUNCTION (ie.  \h CREATE ROLE)

Quit:  \q

Database backup:  pg_dump -U username xportdb -f dbdump.sql

Database restore:  psql -U username -d destinationdb -f dbdump.sql

Leave a Reply

Your email address will not be published. Required fields are marked *