Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/source/user-guide/sql/ddl.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

# DDL

DDL stands for "Data Definition Language" and relates to creating and
modifying catalog objects such as Tables.

## CREATE DATABASE

Create catalog with specified name.
Expand Down
29 changes: 27 additions & 2 deletions docs/source/user-guide/sql/dml.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@

# DML

DML stands for "Data Manipulation Language" and relates to inserting
and modifying data in tables.

## COPY

Copy a table to file(s). Supported file formats are `parquet`, `csv`, and `json`.
Copies the contents of a table or query to file(s). Supported file
formats are `parquet`, `csv`, and `json` and can be inferred based on
filename if writing to a single file.

The `PER_THREAD_OUTPUT` option treats `file_name` as a directory and writes a file per thread within it.

<pre>
COPY <i><b>table_name</i></b> TO '<i><b>file_name</i></b>' [ ( <i><b>option</i></b> [, ... ] ) ]
COPY { <i><b>table_name</i></b> | <i><b>query</i></b> } TO '<i><b>file_name</i></b>' [ ( <i><b>option</i></b> [, ... ] ) ]

where <i><b>option</i></b> can be one of:
FORMAT <i><b>format_name</i></b>
Expand All @@ -35,14 +40,21 @@ where <i><b>option</i></b> can be one of:
ROW_GROUP_LIMIT_BYTES <i><b>integer</i></b>
</pre>

Copy the contents of `source_table` to `file_name.json` in JSON format:

```sql
> COPY source_table TO 'file_name.json';
+-------+
| count |
+-------+
| 2 |
+-------+
```

Copy the contents of `source_table` to one or more Parquet formatted
files in the `dir_name` directory:

```sql
> COPY source_table TO 'dir_name' (FORMAT parquet, PER_THREAD_OUTPUT true);
+-------+
| count |
Expand All @@ -51,6 +63,19 @@ where <i><b>option</i></b> can be one of:
+-------+
```

Run the query `SELECT * from source ORDER BY time` and write the
results (maintaining the order) to a parquet file named
`output.parquet` with a maximum parquet row group size of 10MB:

```sql
> COPY (SELECT * from source ORDER BY time) TO 'output.parquet' (ROW_GROUP_LIMIT_BYTES 10000000);
+-------+
| count |
+-------+
| 2 |
+-------+
```

## INSERT

Insert values into a table.
Expand Down