**Source URL:** https://limited.veevavault.dev/commercial/vault-dx/cli/reference/query

# vault query

Execute a VQL query against the connected Vault and display results as a table, JSON, or CSV.

## Usage

```sh
vault query <QUERY> [--dns <DNS>] [--format <FORMAT>] [--page <N>] [--all]
```

## Options

| Option | Type | Required | Description |
| --- | --- | --- | --- |
| `<QUERY>` | string | Required | The VQL query to execute |
| `--dns <DNS>` | string | Optional | Vault DNS to run against (default: the active vault) |
| `--format <FORMAT>` | `table` | `json` | `csv` | Optional | Output format. Default: `table` |
| `--page <N>` | integer | Optional | Fetch a specific 1-indexed page of results (1000 rows per page). Mutually exclusive with `--all` |
| `--all` | flag | Optional | Fetch and concatenate all pages of results. Mutually exclusive with `--page` |

This command also accepts the [global options](/vault-dx/vault-dx/cli/reference/global-options/).

## Examples

#### Basic query

```sh
vault query "SELECT id__v, name__v FROM documents__v LIMIT 10"
```

#### JSON output

```sh
vault query "SELECT id__v, name__v FROM documents__v" --format json
```

#### CSV output (for piping or import)

```sh
vault query "SELECT id__v, name__v, status__v FROM documents__v" --format csv > documents.csv
```

#### Fetch all pages

```sh
vault query "SELECT id__v FROM documents__v" --all
```

#### Fetch a specific page

```sh
vault query "SELECT id__v FROM documents__v" --page 2
```

## Pagination

The CLI supports two pagination modes:

*   `--page <N>`: Fetch a specific 1-indexed page.
*   `--all`: Fetch every page and concatenate results.

These are mutually exclusive. There is no cross-invocation cursor. Each call independently computes its page using `PAGEOFFSET`.

For VQL syntax, see the [VQL reference](https://general.veevavault.dev/platform/vql/).