PostgreSQL

-- enable formated output
\x on
 
-- show databass
\l
 
-- show tables
\dt
 
-- show user
\du
 
-- drop database
drop database foo;
 
-- exit
\q
 
-- Display tables structure
\d+
 
-- Display tables size
\dT+
 
-- change database
\c dbname
 
-- login to db
sudo -u postgres psql 
 
-- delete database
drop database bar;
 
-- delete user
drop role foo;
 
-- delete all tables
psql zentras -t -c "select 'drop table \"' || tablename || '\" cascade;' from pg_tables where schemaname='public'" | psql
 
# Ansible
https://opensource.com/article/17/6/ansible-postgresql-operations
 
# Links
https://www3.ntu.edu.sg/home/ehchua/programming/sql/PostgreSQL_GetStarted.html
https://www.niwi.nz/2013/02/17/postgresql-database-table-indexes-size/ - SHOW DATABASE, TABLE AND INDEXES SIZE ON POSTGRESQL
https://www.postgresql.org/docs/9.0/static/app-vacuumdb.html
https://www.postgresql.org/docs/9.1/static/app-reindexdb.html