> ## 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.

# REPLACE SINK

> Use the `REPLACE SINK` command to replace an existing sink without backfilling historical data.

## Syntax

```sql theme={null}
REPLACE SINK sink_name
FROM sink_from
WITH (
   connector = 'connector_name',
   connector_parameter = 'value',
   [ snapshot = 'false' ],...
)
[ FORMAT data_format ENCODE data_encode [ (
    format_parameter = 'value'
) ] ];
```

## Parameters

| Parameter                         | Description                                                                                                                                         |
| :-------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------- |
| *sink\_name*                      | The name of the existing sink to replace. `REPLACE SINK` does not create a new sink if the target sink does not already exist.                      |
| *sink\_from*                      | The new upstream source, table, or materialized view for the replacement sink.                                                                      |
| **WITH** clause                   | Specify the connector settings for the replacement sink.                                                                                            |
| *snapshot*                        | **Optional**. If specified, it must be `false`. `REPLACE SINK` is a cut-over operation and does not backfill historical data from the new upstream. |
| **FORMAT** and **ENCODE** options | **Optional**. Specify the sink data format and encoding.                                                                                            |

## Behavior and limitations

* `REPLACE SINK` replaces an existing sink as a cut-over operation. After replacement, the sink starts from the cut-over barrier and only forwards new incremental changes from the new upstream.
* Explicit privileges granted on the existing sink are not migrated to the replacement sink. Re-grant these privileges after replacement.
* Use `REPLACE SINK`, not `CREATE OR REPLACE SINK`.
* `REPLACE SINK` currently supports `FROM` only. `REPLACE SINK ... AS SELECT ...` is not supported.
* `REPLACE SINK` does not support `IF NOT EXISTS`.
* An existing exactly-once sink cannot be replaced.
* Sinks created with `CREATE SINK ... INTO` cannot be replaced.
* Sinks with automatic schema change enabled cannot be replaced, and the replacement definition cannot set `auto.schema.change` to `true`.
* `REPLACE SINK` does not support the `since_timestamp` option.

## Example

```sql theme={null}
REPLACE SINK orders_sink
FROM orders_v2
WITH (
  connector = 'kafka',
  properties.bootstrap.server = 'localhost:9092',
  topic = 'orders',
  primary_key = 'id',
  snapshot = 'false'
)
FORMAT UPSERT ENCODE JSON;
```

## See also

<CardGroup>
  <Card title="CREATE SINK" icon="plus" href="/sql/commands/sql-create-sink" icontype="solid">
    Create a sink
  </Card>

  <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>
</CardGroup>
