Getting Started
Make sure to first set up your PlanetScale developer environment. Once you’ve installed thepscale CLI, you can interact with PlanetScale and manage your databases straight from the command line.
The materialize command
Run Vitess Materialize workflows on a Vitess database branch. Materialize keeps target tables in sync in near-realtime. Targets can be copies, aggregations, or views of source tables.
Prefer move-tables when you only need to copy tables between keyspaces. Prefer Materialize when the target needs a different schema or a SELECT that filters or aggregates rows.
Usage:
pscale branch vtctld materialize also works.
You must be an Organization Administrator or a Database Administrator of the database to create and change Materialize workflows. Service tokens need
read_workflow to show a workflow, write_workflow to create, start, or stop one, and delete_workflow to cancel one.Available sub-commands
* Flag is required
Sub-command flag descriptions
Available flags
Global flags
--table-settings
--table-settings is a JSON array. Each object needs:
target_table— table name in the target keyspacesource_expression— aSELECTagainst a single source table
create_ddl:
"copy"— copy the source table schema as-is- a
CREATE TABLEstatement — create a custom target schema
SELECTs Materialize accepts (no JOINs, no OR/LIKE, expressions need aliases, and more). See the Vitess Materialize docs.
Example:
Lifecycle
- Create the workflow with
--table-settings. - Show the workflow until streams are replicating.
- Read from the target tables once they are in sync.
- Stop / start to pause and resume, or cancel to tear the workflow down.
Examples
Dashboard and API
The Workflows page lists Materialize workflows next to MoveTables workflows and shows stream state, lag, and each target table’s query. It is read-only — create, start, stop, and cancel stay in the CLI or API. See Workflows. Matching API paths under/v1/organizations/:org/databases/:db/branches/:branch/materialize/workflows.

