SQL
Temporary Tables
Temporary tables can be created using the `CREATE TEMP TABLE` or the `CREATE TEMPORARY TABLE` statement (see diagram below).
Temporary tables are session scoped (similar to PostgreSQL for example), meaning that only the specific connection that created them can access them, and once the connection to DuckDB is closed they will be automatically dropped.
Temporary tables reside in memory rather than on disk (even when connecting to a persistent DuckDB), but if the `temp_directory` [configuration](#docs:configuration:overview) is set when connecting or with a `SET` command, data will be spilled to disk if memory becomes constrained.  
Create a temporary table from a CSV file (automatically detecting column names and types):  
```sql
CREATE TEMP TABLE t1 AS
SELECT *
FROM read_csv('path/file.csv');
```  
Allow temporary tables to off-load excess memory to disk:  
```sql
SET temp_directory = '/path/to/directory/';
```  
Temporary tables are part of the `temp.main` schema. While discouraged, their names can overlap with the names of the regular database tables. In these cases, use their fully qualified name, e.g., `temp.main.t1`, for disambiguation.