> ## Documentation Index
> Fetch the complete documentation index at: https://docs.risingwave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CREATE SINK

> Use the `CREATE SINK` command to create a sink. A sink is an external target where you can send data processed in RisingWave. You can create a sink from a table or a materialized view.

If your goal is to create an append-only sink, you can use the emit-on-window-close policy when creating the materialized view that you want to sink data from. For details about the policy, see [Emit on window close](/processing/emit-on-window-close).

## Syntax

```sql theme={null}
CREATE SINK [ IF NOT EXISTS ] sink_name
[FROM sink_from | AS select_query]
WITH (
   connector = 'connector_name',
   connector_parameter = 'value',
   [ snapshot = 'true' | 'false' ],...
)
[ FORMAT data_format ENCODE data_encode [ (
    format_parameter = 'value'
) ] ];
```

## Parameters

| Parameter                         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| :-------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *sink\_name*                      | The name of the sink.                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| *col\_name*                       | The name of the column.                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| *sink\_from*                      | Specify the upstream for the sink: a source, table, or materialized view. For CDC data, the upstream must be a table.                                                                                                                                                                                                                                                                                                                                           |
| *select\_query*                   | Specify the data to be output to the sink.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| *snapshot*                        | **Optional**. Currently, to modify the definition or query of an existing sink, you need to drop and re-create the sink, but this approach generates excessive duplicates due to the mandatory backfilling. To avoid this, you can set the parameter to false to skip the backfilling phase and transmit only incremental changes. This option is only applicable when using the CREATE SINK FROM syntax, not CREATE SINK AS syntax. The default value is true. |
| *force\_compaction*               | **Optional**. When set to `true`, forces buffering and compaction even when the stream key matches the sink primary key exactly. This reduces the number of output messages by emitting at most one update per key within each barrier interval. The default value is `false`. For more information, see [Force compaction](/delivery/overview#force-compaction).                                                                                               |
| **WITH** clause                   | Specify the connector settings here if trying to store all the sink data. See [Supported sinks](#supported-sinks) for the full list of supported sink as well as links to specific connector pages detailing the syntax for each sink.                                                                                                                                                                                                                          |
| **FORMAT** and **ENCODE** options | **Optional**. Specify the data format and the encoding format of the sink data. It is only used for Kafka, Kinesis, Pulsar, and Redis sinks.                                                                                                                                                                                                                                                                                                                    |

<Note>
  Please distinguish between the parameters set in the FORMAT and ENCODE options and those set in the WITH clause. Ensure that you place them correctly and avoid any misuse.
</Note>

## Backfill and isolation

When creating a sink, RisingWave will backfill historical data from the upstream source, table, or materialized view (unless `snapshot=false` is specified). Snapshot backfill is enabled by default to improve isolation between the backfill phase and streaming phase. This helps prevent resource contention between backfilling historical data and processing new streaming data. To disable it if needed, set `SET streaming_use_snapshot_backfill=false;` before creating the sink. For more details, see [View and configure runtime parameters](/operate/view-configure-runtime-parameters).

## Supported sinks

Click a sink name to see the SQL syntax, options, and sample statement of sinking data from RisingWave to the sink.

* [Apache Doris](/integrations/destinations/apache-doris)
* [Apache Iceberg](/integrations/destinations/apache-iceberg)
* [AWS Kinesis](/integrations/destinations/aws-kinesis)
* [Cassandra or ScyllaDB](/integrations/destinations/cassandra-or-scylladb)
* [ClickHouse](/integrations/destinations/clickhouse)
* [CockroachDB](/integrations/destinations/cockroachdb)
* [Delta Lake](/integrations/destinations/delta-lake)
* [Elasticsearch](/integrations/destinations/elasticsearch)
* [Google BigQuery](/integrations/destinations/bigquery)
* [Kafka](/integrations/destinations/apache-kafka) (Supports versions 3.1.0 or later)
* [MySQL](/integrations/destinations/mysql) (Supports versions 5.7 and 8.0.x)
* [NATS](/integrations/destinations/nats-and-nats-jetstream)
* [PostgreSQL](/integrations/destinations/postgresql)
* [Pulsar](/integrations/destinations/apache-pulsar)
* [Redis](/integrations/destinations/redis)
* [StarRocks](/integrations/destinations/starrocks)
* [TiDB](/integrations/destinations/tidb)

## See also

<CardGroup>
  <Card title="Overview of data delivery" icon="truck" icontype="solid" href="/delivery/overview" />

  <Card title="DROP SINK" icon="trash" href="/sql/commands/sql-drop-sink" icontype="solid">
    Remove a sink
  </Card>

  <Card title="SHOW CREATE SINK" icon="eye" href="/sql/commands/sql-show-create-sink" icontype="solid">
    Show the SQL statement used to create a sink
  </Card>

  <Card title="CREATE SINK INTO" icon="plus" href="/sql/commands/sql-create-sink-into" icontype="solid">
    Create a sink into RisingWave's table
  </Card>
</CardGroup>

<Note>
  Timestamptz values are stored in UTC.

  When sinking downstream, the representation of timestamptz is configurable. By default, it is in the format `2023-11-11T18:30:09.453000Z`.
</Note>
