Skip to main content

Get started

Run Postgres queries and DDL from the Console page. The console is available on any database branch. It is disabled for production branches by default to protect production data.
1
From the PlanetScale dashboard, select your Neki database.
2
Select Console.
3
Choose the branch and select Connect.
Once connected, run queries or apply DDL against the branch. Use EXPLAIN or EXPLAIN ANALYZE in front of SELECT, INSERT, UPDATE, and DELETE statements to see how the database executes a query.

Inspect database objects

The console supports a subset of psql meta commands. Type \? or help; to show the complete list in the console. Use \d without a name to list tables, partitioned tables, views, materialized views, sequences, and foreign tables. Add a relation name to inspect its columns, data types, nullability, and defaults:
Use the more specific commands when you only want one type of object. For example, \dt lists tables and \di lists indexes and their definitions. Commands that accept a pattern support * for any number of characters and ? for one character. You can also include a schema name:
\d and \dt also show tables in Neki’s internal __neki schema. Filter with a pattern such as public.* to show only objects in your application schema. Do not use the __neki schema for application objects.
The console accepts \d+, but it returns the same information as \d. Other psql meta commands that are not listed below are not supported.

Logical databases

After connecting to a branch, use the Database dropdown in the console header to choose which logical database to connect to. The default database name is postgres. You can also switch databases from the console prompt with \connect database_name or \c database_name, just like in psql. Run \l to list the available databases on the branch. Switching databases reconnects the console and clears the current output.

Primary and replica connections

After connecting to a branch, use the Server dropdown in the console header to choose which instance to connect to:
  • Primary — Connect to the primary Postgres instance for read and write queries.
  • Replica — Connect to a replica for read-only queries.
If a branch has no replicas, the console connects to the primary and the Replica option is unavailable. Switching between primary and replica reconnects the console and clears the current output.

Connection roles

The console creates a short-lived Postgres role for each connection. The inherited permissions depend on the selected server and your organization or database role. Tables created during a web console session are reassigned to the postgres role shortly after the session ends. Until reassignment completes, newly created tables may temporarily appear owned by the console’s short-lived role.

Development branches

All organization roles (member, analyst, administrator) have full read and write access to development branch consoles on the primary. On a replica, the console always uses a read-only role.

Production branches

Production branch console access also requires the web console setting to be enabled. Once enabled, access depends on your role: On a replica, the console always uses a read-only role with pg_read_all_data, regardless of your primary permissions.

Supported console commands

Commands with uppercase letters, including \dD, \dO, and \dT, are case sensitive.

Keyboard shortcuts

Enable for production branches

By default, the web console is disabled for production branches to prevent accidental data loss. You can enable the web console for production branches on the Settings page for the given database, app.planetscale.com/<org>/<database>/settings. Select the checkbox for Allow web console access to production branches, then scroll down and select Save database settings to save your changes. This enables the web console to run queries against production branches for the given database.

Need help?

Get help from the PlanetScale Support team, or join our Discord community to see how others are using PlanetScale.