Databases

Installation

Running the system

initdb /usr/local/var/postgres -E utf8
brew services start postgres
createdb <user>
psql

Create a new user and grant permissions

CREATE USER <username>
ALTER USER <username> with encrypted password '<password>';
ALTER USER <username> with CREATEDB;

Create role and alter role permissions

CREATE ROLE <groupname> WITH <role1>, <role2>;
GRANT <groupname> TO <username>
REVOKE <groupname> TO <username>

Play with PSQL

\du
\l
\c <database name>\dt
psql -h localhost -p 5432 -U postgres
\d "<relation name>"
psql -f <filepath> -q <dbname> <username>

CODER | BLOGGER | ARTIST | GHOST