Postgres Schema

Postgres Schema

Simple tutorial to show some command that let you operate with your postgreSQL and schema.

Connect to your database.

Let’s say is your postgres host.

psql -h 10.XX.XX.185 -U postgres

List databases


Every schema were attached with a database, now connect to the database.

\c [database_name]

List all schema tables

\dt *.*

List particular schema tables

\dt scheduler.*

Describe table

\d [schema].[table_name]

Sample alter command

ALTER TABLE [schema].[column] ALTER COLUMN [column_name] TYPE text;


Backup command

./pg_dump -h {db-host} -U {username} {database} -f {path_to_backup.sql}


./pg_dump -h -U postgres -d mydatabase -f mydatabase.sql


Restore command

./psql -h {db-host} -U {username} -d {database}  -f {path_to_backup.sql}


./psql -U postgres -d mydatabase -f  /Users/mingch/Documents/mydatabase.sql



Write a Reply or Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.