psql Command Examples

PostgreSQL command-line client. More information: https://www.postgresql.org/docs/current/app-psql.html.

psql {{database}}

psql {{[-h|--host]}} {{host}} {{[-p|--port]}} {{port}} {{[-U|--username]}} {{username}} {{database}}

psql {{[-h|--host]}} {{host}} {{[-p|--port]}} {{port}} {{[-U|--username]}} {{username}} {{[-W|--password]}} {{database}}

psql {{[-c|--command]}} '{{query}}' {{database}}

psql {{database}} {{[-f|--file]}} {{file.sql}}