psql
ConnectionPostgreSQL interactive terminal
Options & Flags
Available options for this command
-hSpecify database server host
-pSpecify database server port
-UConnect as specified database user
-dSpecify database name to connect to
-cExecute a single command and exit
-fExecute commands from a file
Examples
Common usage examples
Connect as postgres user
psql -U postgresConnect to specific database on localhost
psql -h localhost -U myuser -d mydbExecute single query and exit
psql -c 'SELECT version();'Run SQL script on database
psql -f script.sql mydbNotes
- Use \q to quit psql
- Use \? for help on psql commands
Related Commands
You might also find these useful