Skip to main content

TEMPORARY TABLES

The CREATE TEMPORARY TABLE statement creates a new a temporary from a sql query. This command is used to create a local temporary table. More information can be found in the DuckDB documentation.

Syntax​

CREATE [ OR REPLACE ] TEMPORARY TABLE [ IF NOT EXISTS ] <table name> AS ...

Temporary Tables can be created traditionally with column names and types, or with Create Table ... As Select (CTAS).

Shorthand Convention​

The word TEMP can be used interchangably with TEMPORARY.

Example Usage​

CREATE TEMPORARY TABLE flights AS
FROM 'https://duckdb.org/data/flights.csv';

This will create a local table with data from the duckdb flights.csv file.

Notes​

  • Temporary Tables in MotherDuck persist locally, not on the server. As such, local constraints should be considered when using them.
  • Because they are bound to your session, when your session ends, any temporary tables will no longer be available.