# DECLARE
`DECLARE` creates a cursor.

> For the complete documentation index, see [llms.txt](https://preview.materialize.com/materialize/40269/llms.txt).


`DECLARE` creates a cursor, which can be used with
[`FETCH`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/fetch/index.md), to retrieve a limited number of rows at a time
from a larger query. Large queries or queries that don't ever complete
([`SUBSCRIBE`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/subscribe/index.md)) can be difficult to use with many PostgreSQL drivers
that wait until all rows are returned before returning control to an
application. Using `DECLARE` and [`FETCH`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/fetch/index.md) allows you to
fetch only some of the rows at a time.

## Syntax

```mzsql
DECLARE <cursor_name> CURSOR FOR <query>;
```

Syntax element | Description
---------------|------------
`<cursor_name>` | The name of the cursor to be created.
`<query>` | The query ([`SELECT`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/select/index.md) or [`SUBSCRIBE`](https://preview.materialize.com/materialize/40269/markdown-docs/sql/subscribe/index.md)) that will provide the rows to be returned by the cursor.
