Skip to content

Instantly share code, notes, and snippets.

@Jonalogy
Created February 18, 2020 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jonalogy/f2aab06148b167481c09c5ac3fa69bc1 to your computer and use it in GitHub Desktop.
Save Jonalogy/f2aab06148b167481c09c5ac3fa69bc1 to your computer and use it in GitHub Desktop.
PSQL Basics

Connecting to PostgreSQL via CLI using PSQL

Ensure you have PSQL installed

Connecting to your DB

psql --host=localhost --port=5432 --username=developer --dbname=dummyDb --password

Once connected,

  • list your tables with \d
  • If you have a simple query simple type into the cli and execute your query directly.
  • If you have a query thats too long, you can choose to load your query into the buffer using \e.
  • To execute your query stored in the buffer, run \g.
  • To quite psql, run \q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment