Skip to main content

CREATE SINK INTO

Use the CREATE SINK INTO command to create a sink into RisingWave's table.

Syntax

CREATE SINK [ IF NOT EXISTS ] sink_name INTO table_name
[FROM sink_from | AS select_query]
note

A table without a primary key can only accept the append-only sink.

note

Currently, if there are sinks in the table, the table cannot be altered to add or drop columns.

Examples

You can union data from two different Kafka topics.

CREATE TABLE orders (
id int primary key,
price int,
item_id int,
customer_id int
);

CREATE source orders_s0 (
id int primary key,
price int,
item_id int,
customer_id int
) WITH (
connector = 'kafka',
topic = 'topic_0',
...
) FORMAT PLAIN ENCODE JSON;

CREATE source orders_s1 (
id int primary key,
price int,
item_id int,
customer_id int
) WITH (
connector = 'kafka',
topic = 'topic_1',
...
) FORMAT PLAIN ENCODE JSON;

CREATE SINK orders_sink0 INTO orders FROM orders_s0;
CREATE SINK orders_sink1 INTO orders FROM orders_s1;

If you don't want one of the topics, you can drop it.

DROP SINK orders_sink0;

See also

CREATE SINK — Create a sink into an external target.

DROP SINK — Remove a sink.

SHOW CREATE SINK — Show the SQL statement used to create a sink.

Help us make this doc better!

Was this page helpful?

Happy React is loading...