Skip to content

Instantly share code, notes, and snippets.

@bonniss
Last active August 13, 2022 21:19
Show Gist options
  • Save bonniss/5c85caf8118770ae742da60c09bfed1b to your computer and use it in GitHub Desktop.
Save bonniss/5c85caf8118770ae742da60c09bfed1b to your computer and use it in GitHub Desktop.
PSQL Common Lines

Installation

Chocolatey

choco install postgresql13 --params '/Password:159753 /Port:5432'
psql -Upostgres
ALTER USER postgres WITH PASSWORD 'new_password';

Issues

Commonly used PSQL commands

Connect to a database of a specified host

psql -d {db_name} -h {hostname} -p {port} -U {db_username}

→ psql -d pg_northwind -h 121.125.44.211 -p 5432 -U postgres

Enter as user (typically postgres)

psql -U postgres

List all databases

\l

Connect to a database

\c {datbase_name}

"show table" in a database

\dt

Show table schema/"describe table"

\d+ {table_name_accept_wildcard}
@bonniss
Copy link
Author

bonniss commented Apr 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment