data.haus blog

minimal tech for today

Postgres commands

2019-04-08 - psic4t

Only for absolute n00bs (like me).

su - postgres
psql
\l # lists all dbs
\c dbname # connects to dbname
\dt # show tables

Create a new db:

CREATE DATABASE synapse
 ENCODING 'UTF8'
 LC_COLLATE='C'
 LC_CTYPE='C'
 template=template0
 OWNER synapse_user;

Dump a db to file:

pg_dump -U postgres -W -F t mydb > /tmp/mydb.tar

W asks for password, F output file format which is ’t' here, for tar

Dump all databases to file:

pg_dumpall -U postgres > /tmp/alldbs.sql

Show vacuum progress:

select * from pg_stat_progress_vacuum;
View more postsRSS