cockroachdb/cockroach
cockroach-sql
A standalone SQL client built from the same shell as cockroach sql. Source: pkg/cmd/cockroach-sql/. The shell itself lives in pkg/cli/clisqlshell/.
Why a separate binary
cockroach-sql ships without the rest of the database — no Pebble, no KV server, no UI assets. The binary is small (a few tens of MB) and is the recommended way to script CockroachDB from CI environments where the full server binary would be wasteful.
Capabilities
The shell supports:
- TLS via certs or insecure connections.
- Tab completion against
crdb_internalandpg_catalog. \help,\d,\dt,\du,\df,\connect, and PostgreSQL psql-compatible meta-commands.- Multi-line statement editing with syntax highlighting.
- Prompt customization (
COCKROACH_PSQL_PROMPT). \demomode interaction.EXPLAIN ANALYZE (DEBUG)bundle download.
Code reuse
cockroach-sql is a thin wrapper around:
pkg/cli/clisqlcfg/— config struct.pkg/cli/clisqlclient/— connection setup and PG protocol handling.pkg/cli/clisqlexec/— command execution and result formatting.pkg/cli/clisqlshell/— interactive REPL.pkg/cli/clienturl/— connection-string discovery and resolution.
Related pages
- apps/cockroach — embeds the same shell as
cockroach sql. - SQL — the server-side SQL stack.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.