---
title: "scratch - Xata"
description: "Run SQL or a Postgres client command against a temporary scratch branch"
source: "https://xata.io/docs/cli/scratch"
---

Skip to main content

Creates a branch from the parent given, runs what it is asked to, and deletes the branch afterwards, so a query or a migration can be tried against real data without touching an existing branch. This command also takes `-h, --help`.

## ​scratch

Run SQL or a Postgres client command against a temporary scratch branch Creates a branch from the parent given, runs what it is asked to, and deletes the branch afterwards, so a query or a migration can be tried against real data without touching an existing branch.

```
xata scratch [--organization value] [--project value] [--parent-branch value] [--database value] [--execute value] [--json] [--profile value] <command>...
```

​

string

Organization ID

​

string

Project ID

​

string

Source branch ID for the scratch branch

​

string

Database name

​

string

SQL query to execute in the scratch branch

​

boolean

default:"false"

Output SQL query results in JSON format

​

string

The profile to use

​

string

Binary command to run with scratch database environment variables

**Examples:**

```
# Run a query against a throwaway copy
xata scratch --execute "select count(*) from users"
# Open a Postgres client on the scratch branch
xata scratch psql
```

Was this page helpful?
