Available in versions: Dev (3.21)
This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.
Local temporary tables
Supported by ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
A LOCAL TEMPORARY table is a table whose meta data and data are local to a session or transaction.
// Create a new temporary table
create.createLocalTemporaryTable("book_archive")
.column("column1", INTEGER)
.execute();
The SQL standard also specifies aLOCAL TEMPORARYsyntax with a different semantics, where the locality is with respect to a "SQL module," not a session or transaction. Many RDBMS use the keywordLOCALwith a different meaning from the standard, and thus jOOQ follows the implementations here, not the standard.
Historically, jOOQ also supported the CREATE TEMPORARY TABLE syntax via DSLContext.createTemporaryTable(Table) (without explicit GLOBAL or LOCAL keyword):
// Create a new temporary table
create.createTemporaryTable("book_archive")
.column("column1", INTEGER)
.execute();
-
GLOBAL TEMPORARYif it's supported by a dialect -
LOCAL TEMPORARYotherwise
This alternative syntax is still supported, but no longer recommended with jOOQ 3.21, as the two types of temporary tables work quite differently.
Dialect support
This example using jOOQ:
createLocalTemporaryTable("book_archive")
.column("column1", INTEGER)
Translates to the following dialect specific expressions:
Aurora MySQL, DuckDB, MariaDB, MemSQL, MySQL, Redshift, Vertica, YugabyteDB
CREATE TEMPORARY TABLE book_archive ( column1 int )
BigQuery
CREATE TEMPORARY TABLE book_archive ( column1 int64 )
ClickHouse
CREATE TEMPORARY TABLE book_archive ( column1 Nullable(integer) ) ENGINE Log()
CockroachDB
CREATE TEMPORARY TABLE book_archive ( column1 int4 )
DB2
DECLARE GLOBAL TEMPORARY TABLE book_archive ( column1 integer )
H2
CREATE LOCAL TEMPORARY TABLE book_archive ( column1 int )
Hana
CREATE LOCAL TEMPORARY TABLE book_archive ( column1 integer )
Oracle
CREATE PRIVATE TEMPORARY TABLE book_archive ( column1 number(10) )
Snowflake
CREATE TEMPORARY TABLE book_archive ( column1 number(10) )
SQLServer
CREATE TABLE #book_archive ( column1 int )
ASE, Access, Aurora Postgres, Databricks, Exasol, Firebird, HSQLDB, Informix, Postgres, SQLDataWarehouse, SQLite, Spanner, Sybase, Teradata, Trino
/* UNSUPPORTED */
Generated with jOOQ 3.21. Support in older jOOQ versions may differ. Translate your own SQL on our website
Feedback
Do you have any feedback about this page? We'd love to hear it!