1919
2020# DML
2121
22+ DML stands for "Data Manipulation Language" and relates to inserting
23+ and modifying data in tables.
24+
2225## COPY
2326
24- Copy a table to file(s). Supported file formats are ` parquet ` , ` csv ` , and ` json ` .
27+ Copies the contents of a table or query to file(s). Supported file
28+ formats are ` parquet ` , ` csv ` , and ` json ` and can be inferred based on
29+ filename if writing to a single file.
2530
2631The ` PER_THREAD_OUTPUT ` option treats ` file_name ` as a directory and writes a file per thread within it.
2732
2833<pre >
29- COPY <i ><b >table_name</i ></b > TO '<i ><b >file_name</i ></b >' [ ( <i ><b >option</i ></b > [, ... ] ) ]
34+ COPY { <i ><b >table_name</i ></b > | < i >< b >query</ i ></ b > } TO '<i ><b >file_name</i ></b >' [ ( <i ><b >option</i ></b > [, ... ] ) ]
3035
3136where <i ><b >option</i ></b > can be one of:
3237 FORMAT <i ><b >format_name</i ></b >
@@ -35,14 +40,21 @@ where <i><b>option</i></b> can be one of:
3540 ROW_GROUP_LIMIT_BYTES <i ><b >integer</i ></b >
3641</pre >
3742
43+ Copy the contents of ` source_table ` to ` file_name.json ` in JSON format:
44+
3845``` sql
3946> COPY source_table TO ' file_name.json' ;
4047+ -- -----+
4148| count |
4249+ -- -----+
4350| 2 |
4451+ -- -----+
52+ ```
53+
54+ Copy the contents of ` source_table ` to one or more Parquet formatted
55+ files in the ` dir_name ` directory:
4556
57+ ``` sql
4658> COPY source_table TO ' dir_name' (FORMAT parquet, PER_THREAD_OUTPUT true);
4759+ -- -----+
4860| count |
@@ -51,6 +63,19 @@ where <i><b>option</i></b> can be one of:
5163+ -- -----+
5264```
5365
66+ Run the query ` SELECT * from source ORDER BY time ` and write the
67+ results (maintaining the order) to a parquet file named
68+ ` output.parquet ` with a maximum parquet row group size of 10MB:
69+
70+ ``` sql
71+ > COPY (SELECT * from source ORDER BY time ) TO ' output.parquet' (ROW_GROUP_LIMIT_BYTES 10000000 );
72+ + -- -----+
73+ | count |
74+ + -- -----+
75+ | 2 |
76+ + -- -----+
77+ ```
78+
5479## INSERT
5580
5681Insert values into a table.
0 commit comments