SQL
Examples
Read a CSV file into the `lineitem` table, using auto-detected CSV options:  
```sql
COPY lineitem FROM 'lineitem.csv';
```  
Read a CSV file into the `lineitem` table, using manually specified CSV options:  
```sql
COPY lineitem FROM 'lineitem.csv' (DELIMITER '|');
```  
Read a Parquet file into the `lineitem` table:  
```sql
COPY lineitem FROM 'lineitem.pq' (FORMAT PARQUET);
```  
Read a JSON file into the `lineitem` table, using auto-detected options:  
```sql
COPY lineitem FROM 'lineitem.json' (FORMAT JSON, AUTO_DETECT true);
```  
Read a CSV file into the `lineitem` table, using double quotes:  
```sql
COPY lineitem FROM "lineitem.csv";
```  
Read a CSV file into the `lineitem` table, omitting quotes:  
```sql
COPY lineitem FROM lineitem.csv;
```  
Write a table to a CSV file:  
```sql
COPY lineitem TO 'lineitem.csv' (FORMAT CSV, DELIMITER '|', HEADER);
```  
Write a table to a CSV file, using double quotes:  
```sql
COPY lineitem TO "lineitem.csv";
```  
Write a table to a CSV file, omitting quotes:  
```sql
COPY lineitem TO lineitem.csv;
```  
Write the result of a query to a Parquet file:  
```sql
COPY (SELECT l_orderkey, l_partkey FROM lineitem) TO 'lineitem.parquet' (COMPRESSION ZSTD);
```  
Copy the entire content of database `db1` to database `db2`:  
```sql
COPY FROM DATABASE db1 TO db2;
```  
Copy only the schema (catalog elements) but not any data:  
```sql
COPY FROM DATABASE db1 TO db2 (SCHEMA);
```