Skip to content
P PgShell

Commands and interactive UI

Use the CLI for automation and quick tasks, or the interactive menu when you prefer guided steps. Credentials come from .env / DATABASE_URL, stored profiles, or interactive prompts when you run in a terminal. The query command also needs a target database (for example DB_NAME or a database in your connection URL).

CLI commands

Non-zero exit code on error.

Command Description
pgshell, pgshell ui, pgshell viewLaunch the interactive menu.
pgshell query "<sql>"Run a raw SQL query. Supports --json / --csv.
pgshell exec <file.sql>Run a SQL file against the target database.
pgshell listList databases with sizes.
pgshell create <name>Create a new database.
pgshell drop <name>Drop a database. Use --yes to skip confirmation.
pgshell table [dbName]List tables; optional database name or interactive pick.
pgshell delete [dbName]Clear public tables, views, sequences, types, and functions. Extension objects stay.
pgshell doctorConnection health: latency, version, SSL, credential source.
pgshell config show|clearInspect or clear the saved profile (password never printed).
pgshell completion <shell>Print bash / zsh / powershell completion.

Global flags

--json, --csv, -q / --quiet — scripting-friendly output. Prefer --json when both --json and --csv are set.

Examples

pgshell query "SELECT * FROM users LIMIT 5" --json
pgshell exec ./seed.sql
pgshell list --csv
pgshell doctor --json
pgshell config show
eval "$(pgshell completion bash)"

Interactive menu

Run pgshell or pgshell ui.

Option What it does
List all databasesDatabases with sizes.
Create databaseCreate a new database.
Delete databaseDrop a database with confirmation.
Switch databaseReconnect to another database.
List all tablespublic schema: owner and row estimates.
View table dataBrowse rows with a configurable limit.
Table structureColumns, types, nullability, defaults.
Create new tableDefine tables with column syntax.
Add new rowInsert with guided prompts.
Delete one tableDrop one table, then unused types and functions.
Clean public schemaDrop public tables, views, sequences, enums, and functions. Extension objects stay.
Run custom SQLExecute arbitrary SQL.
Recent queriesRe-run from local history (~/.pgshell/history.json).
Monitor active queriesLive view of running queries.
Disconnect and exitClose the connection and quit.
Re-setup credentialsUpdate the stored password (for example after a password change).

Tips

Something not working? See Troubleshooting.