Skip to main content

Getting Started

Make sure to first set up your PlanetScale developer environment. Once you’ve installed the pscale CLI, you can interact with PlanetScale and manage your databases straight from the command line.

The branch command

This command allows you to create, delete, diff, and manage branches. Usage:

Available sub-commands

Service token automation: branch

Legend: ✅ supported · 🚫 unavailable · 👤 interactive login only. All sub-commands require --org or PLANETSCALE_ORG.
Setup and commands to avoid: CLI overview · Service tokens
* Flag is required

Sub-command flag descriptions

Some of the sub-commands have additional flags unique to the sub-command. This section covers what each of those does. See the above table for which context.
The --region flag can not be used with --restore when creating a branch. Branch backups will be restored to their original region.

Available flags

Global flags

Examples

The connections sub-command

Command:
Opens a live view of the branch’s connection activity. It works for Postgres and Vitess branches; for Vitess, pass --keyspace and --shard to target a tablet, or run interactively to select them. See the connections reference, Inspect live Postgres connections, and Inspect live Vitess connections for the full workflow.

The query-patterns sub-command

Command:
Creates a Query Insights report for the branch, waits for it to finish generating, and downloads the CSV file. Use --output to choose the file path. See the query-patterns reference for the full workflow.

The list sub-command with --web flag

Command:
Output: Opens the Branches page, <https://app.planetscale.com/org/database/branches>, in browser.

The parameters sub-command

Command:
Lists the configuration parameters of a Postgres branch, including their current values, defaults, allowed ranges, and whether changing them requires a restart. Use --namespace to limit the output to a single namespace such as pgconf, pgbouncer, or patroni.

The resize sub-command

Command:
Creates a change request for a Postgres branch. A single change request can update the cluster size (--cluster-size), the number of replicas (--replicas), and configuration parameters (--parameters, repeatable) together. With --wait, the command polls until the change request completes; without it, the command returns immediately and you can follow up with resize status. Some parameters require a database restart to take effect; the command tells you which ones before the change is applied. Command:
Shows the latest change request for the branch, including its state (queued, pending, resizing, completed, or canceled) and what it changes. Command:
Cancels the queued change request for the branch. Only change requests that have not started being applied can be canceled.

The diff sub-command

Command:
Output:
This will return the diff against the parent branch.

Need help?

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