COPY command allows you to export query results from RisingWave to standard output (STDOUT) in tab-separated values (TSV) format. This is useful for integrating RisingWave with external systems that can consume PostgreSQL-compatible COPY output, such as ClickHouse’s PostgreSQL table engine.
Syntax
Parameters
| Parameter | Description |
|---|---|
| query | A SELECT query that specifies the data to export. |
Output format
TheCOPY TO STDOUT command outputs data in TSV format with the following characteristics:
- Fields are separated by tab characters (
\t) - Rows are separated by newline characters (
\n) - NULL values are represented as empty fields
- Special characters are escaped:
- Tab characters in data are escaped as
\t - Newline characters in data are escaped as
\n - Carriage return characters in data are escaped as
\r - Backslash characters in data are escaped as
\\
- Tab characters in data are escaped as
Examples
Export results from a simple query:Basic example
Example with special characters
Integration with ClickHouse
TheCOPY TO STDOUT command enables ClickHouse to query RisingWave data using the PostgreSQL table engine. ClickHouse uses this syntax internally when loading data from PostgreSQL-compatible databases.
Example ClickHouse configuration:
COPY () TO STDOUT to efficiently load data from RisingWave.
Related topics
- ClickHouse sink — Send data from RisingWave to ClickHouse