PostgreSQL Simple Commands

created:

updated:

tags: postgresql database

I have some simple PostgreSQL commands that I repeatedly use for work or side projects and want to record some here for future usage.

Create a New Database

CREATE DATABASE name WITH option ...

where option can be OWNER, ALLOW_CONNECTIONS, etc.

Create a New User

CREATE USER WITH option ...

where option can be uid, CREATEDB, PASSWORD 'password', etc.

Assign the Owner of a Database to a User

ALTER DATABASE db_name OWNER TO new_owner;

References