SQL
`COPY ... FROM`
`COPY ... FROM` imports data from an external file into an existing table. The data is appended to whatever data is in the table already. The amount of columns inside the file must match the amount of columns in the table `table_name`, and the contents of the columns must be convertible to the column types of the table. In case this is not possible, an error will be thrown.  
If a list of columns is specified, `COPY` will only copy the data in the specified columns from the file. If there are any columns in the table that are not in the column list, `COPY ... FROM` will insert the default values for those columns  
Copy the contents of a comma-separated file `test.csv` without a header into the table `test`:  
```sql
COPY test FROM 'test.csv';
```  
Copy the contents of a comma-separated file with a header into the `category` table:  
```sql
COPY category FROM 'categories.csv' (HEADER);
```  
Copy the contents of `lineitem.tbl` into the `lineitem` table, where the contents are delimited by a pipe character (` |`):  
```sql
COPY lineitem FROM 'lineitem.tbl' (DELIMITER '|');
```  
Copy the contents of `lineitem.tbl` into the `lineitem` table, where the delimiter, quote character, and presence of a header are automatically detected:  
```sql
COPY lineitem FROM 'lineitem.tbl' (AUTO_DETECT true);
```  
Read the contents of a comma-separated file `names.csv` into the `name` column of the `category` table. Any other columns of this table are filled with their default value:  
```sql
COPY category(name) FROM 'names.csv';
```  
Read the contents of a Parquet file `lineitem.parquet` into the `lineitem` table:  
```sql
COPY lineitem FROM 'lineitem.parquet' (FORMAT PARQUET);
```  
Read the contents of a newline-delimited JSON file `lineitem.ndjson` into the `lineitem` table:  
```sql
COPY lineitem FROM 'lineitem.ndjson' (FORMAT JSON);
```  
Read the contents of a JSON file `lineitem.json` into the `lineitem` table:  
```sql
COPY lineitem FROM 'lineitem.json' (FORMAT JSON, ARRAY true);
```  
#### Syntax {#docs:sql:statements:copy::syntax}  
<div id="rrdiagram1"></div>