Postgres basics

From Origami_Wiki
Revision as of 14:50, 16 June 2017 by imported>Kishor (Created page with "Get postgres prompt su postgres<br> psql<br> postgres=#<br> su postgres<br> psql <dbname><br> [edit] List databases<br> postgres=# \l<br> [edit] List users<br> postgres=...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Get postgres prompt

su postgres
psql
postgres=#

su postgres
psql <dbname>

[edit] List databases

postgres=# \l

[edit] List users

postgres=# \du

[edit] Dump a database

su postgres
pg_dump <dbname> > db.out

[edit] Import a database

su postgres
psql -d <dbname> -f db.out

[edit] Create role

createuser -S -D -R <role_name>

PG RESTORE COMMAND



pg_restore -h localhost -U origami_dbadmin -d kvvs -W kvvs_20170316_22_00_01.tar


PG DUMP COMMAND



pg_dump -Ft -U origami_dbadmin ddugky_misdbnew -x -O -f "/var/www/html/ddugky_mis_2/ddugky_misdb.tar"


PG DUMP WITHOUT VERSION PROBLEMS (plain format dump file)



pg_dump -f ddugky_misdbnew.db -F p -U origami_dbadmin ddugky_misdbnew
pg_dump -U username dbname > dump.sql


PG RESTORE WITHOUT VERSION PROBLEMS (plain format dump file)



psql -f ddugky_misdbnew.db dd_misdb origami_dbadmin