> ## Documentation Index
> Fetch the complete documentation index at: https://risingwavelabs-wyx-add-timestamp-dedicated-page.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# CREATE MATERIALIZED VIEW

> Use the `CREATE MATERIALIZED VIEW` command to create a materialized view. A materialized view can be created based on sources, tables, materialized views, or indexes.

## Syntax

```sql theme={null}
CREATE MATERIALIZED VIEW [IF NOT EXISTS] mv_name AS select_query;
```

<Tip>
  `CREATE MATERIALIZED VIEW` will first **backfill** historical data from the referenced relations, and completion time varies based on the volume of data to be backfilled.

  To perform the operations in the background, you can execute `SET BACKGROUND_DDL=true;` before running the `CREATE MATERIALIZED VIEW` statement. See details in [SET BACKGROUND\_DDL](/sql/commands/sql-set-background-ddl).
</Tip>

## Parameters

| Parameter or clause | Description                                                                                                                                             |
| :------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------ |
| *mv\_name*          | The name of the materialized view to be created.                                                                                                        |
| *select\_query*     | A SELECT query that retrieves data for the materialized view. See [SELECT](/sql/commands/sql-select) for the syntax and examples of the SELECT command. |

<Note>
  Names and unquoted identifiers are case-insensitive. Therefore, you must double-quote any of these fields for them to be case-sensitive. See also [Identifiers](/sql/identifiers).
</Note>

<Note>
  The `ORDER BY` clause in the `CREATE MATERIALIZED VIEW` statement is allowed but not considered as part of the definition of the materialized view. It's only used in the initial creation of the materialized view and not during refreshes.
</Note>

## See also

<CardGroup>
  <Card title="Overview of data processing" icon="database" href="/processing/overview" horizontal />
</CardGroup>
