Use the CREATE TABLE
command to create a new table. Tables consist of fixed columns and insertable rows.
A1
is defined as current_timestamp()
, then it cannot be part of the primary key.
<column_name> timestamptz AS proctime()
) when creating the table or source. See also proctime().
*
to represent all columns from the external connector first, so that you can define a generated column on table with an external connector. Alternatively, you can partially combine the schema with generated columns or apply the schema directly to define the table structure. See the examples below:
Parameter or clause | Description |
---|---|
table_name | The name of the table. If a schema name is given (for example, CREATE TABLE <schema>.<table> …), then the table is created in the specified schema. Otherwise it is created in the current schema. |
col_name | The name of a column. |
data_type | The data type of a column. With the struct data type, you can create a nested table. Elements in a nested table need to be enclosed with angle brackets (<>). |
DEFAULT | The DEFAULT clause allows you to assign a default value to a column. This default value is used when a new row is inserted, and no explicit value is provided for that column. default_expr is any constant value or variable-free expression that does not reference other columns in the current table or involve subqueries. The data type of default_expr must match the data type of the column. |
generation_expression | The expression for the generated column. For details about generated columns, see Generated columns. |
watermark_clause | A clause that defines the watermark for a timestamp column. The syntax is WATERMARK FOR column_name as expr. For the watermark clause to be valid, the table must be an append-only table. That is, the APPEND ONLY option must be specified. This restriction only applies to a table. For details about watermarks, See Watermarks below for more. |
APPEND ONLY | When this option is specified, the table will be created as an append-only table. An append-only table cannot have primary keys. UPDATE and DELETE statements are not valid for append-only tables. See Watermarks below for more. |
ON CONFLICT | Specify the alternative action when the newly inserted record brings a violation of PRIMARY KEY constraint on the table. See PK conflict behavior below for more information. |
INCLUDE clause | Extract fields not included in the payload as separate columns. For more details on its usage, see INCLUDE clause. |
WITH clause | Specify the connector settings here if trying to store all the source data. See the Data ingestion page for the full list of supported source as well as links to specific connector pages detailing the syntax for each source. |
FORMAT and ENCODE options | Specify the data format and the encoding format of the source data. To learn about the supported data formats, see Data formats and encoding options. |
ENGINE | Specify the Iceberg table engine to store data natively in the Iceberg format. For more information, see Create a table with the Iceberg engine. |
CREATE TABLE
statement, you can specify ENGINE = iceberg
to store table data in the Apache Iceberg format on external object storage. This provides an alternative to RisingWave’s default internal row-based storage, making it easier to persist data for long-term use and cross-system access. For more information on the syntax and usage, see Iceberg table engine.
DELETE
statements. Therefore, RisingWave provides TTL (Time-To-Live) feature to automatically clean up expired data in the table.
However, please note that this cleanup only applies to the data within the table itself—it does not affect downstream materialized views or other streaming jobs. If you need to clean up data in downstream materialized views used in queries, you should use a Temporal Filter in the downstream streaming job.
ON CONFLICT conflict_action
clause will be adopted. The record can come from an INSERT
statement, external connectors of the table, or sinks into the table.
The conflict_action
could be one of the following. A version column can be specified together for DO UPDATE FULL
and DO UPDATE IF NOT NULL
. When a version column is specified, the insert operation will take effect only when the newly inserted row’s version column is greater than or equal to the existing row’s version column, and is not NULL.
IGNORE
: Ignore the newly inserted record.OVERWRITE [WITH VERSION COLUMN(col_name)]
: Full update: replace the existing row in the table with the new row.DO UPDATE IF NOT NULL [WITH VERSION COLUMN(col_name)]
: Partial update: only replace those fields with non-NULL values in the inserted row. NULL values in the inserted row means unchanged in this case.DO UPDATE IF NOT NULL
behavior is applied, DEFAULT
clause is not allowed on the table’s columns.OVERWRITE
and DO UPDATE IF NOT NULL
to tune the conflict handling behaviors.
Common use cases include:
DELETE
statement.
This can be used to implement in-place streaming job modification, or re-sync external batch data into RisingWave (reverse ETL).
SELECT * EXCEPT(version_col)
to avoid depending on the version column by mistake.