SQL Notes for PostgreSQL

High Availability and Balance Loading References

  1. PostgreSQL Documentation: Chapter 26. High Availability, Load Balancing, and Replication
  2. repmgr
  3. PostgreSQL Cluster does not match standard definition of cluster: What’s a PostgreSQL “Cluster” and how do I create one?.
  4. Wiki on replication.

Create DB User and Database for Application

Create DB User:

CREATE USER name_u WITH
LOGIN NOSUPERUSER CREATEROLE -- CREATEDB
INHERIT
NOREPLICATION
CONNECTION LIMIT -1
PASSWORD 'type_password_here';

Create Database:

create database db_name with ENCODING 'UTF-8' owner name_u;

CREATE DATABASE time_series
    WITH 
    OWNER = postgres
    ENCODING = 'UTF8'
    CONNECTION LIMIT = -1;

Update Password

ALTER USER user_name WITH PASSWORD 'new_password';

Official documentation on how to alter user.