On this page
Postgresql Tips
On this page
0. Enter psql
psql
Show all databases
\l
Enter Database
\c database_name
Show all Tables
\d
Show Table structure
\d table_name
Pretty print table
\x on
Alter table
See https://www.postgresql.org/docs/current/sql-altertable.html
Upsert
Export Schema
pg_dump database_name -s --no-owner > schema.sql
Export Only data
pg_dump database_name -a --no-owner > data.sql
Delete or Drop or Remove Database
psqldrop database database_name;
Create Database
psqlCREATE DATABASE name;
Import Database
psql database_name < data.sql
Tags
Edit this page
Last updated on 1/25/2022