Available in versions: Dev (3.21) | Latest (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11
Global temporary tables
Supported by ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
A GLOBAL TEMPORARY table is a table whose meta data is shared among all sessions or transaction, but where each session or transaction contains its own data. It acts like a table with a session or transaction based policies enabled.
// Create a new temporary table
create.createGlobalTemporaryTable("book_archive")
.column("column1", INTEGER)
.execute();
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:
createGlobalTemporaryTable("book_archive")
.column("column1", INTEGER)
Translates to the following dialect specific expressions:
Aurora Postgres, H2, Vertica
CREATE GLOBAL TEMPORARY TABLE book_archive ( column1 int )
DB2, Firebird, Hana, Teradata
CREATE GLOBAL TEMPORARY TABLE book_archive ( column1 integer )
MemSQL
CREATE ROWSTORE GLOBAL TEMPORARY TABLE book_archive ( column1 int )
Oracle
CREATE GLOBAL TEMPORARY TABLE book_archive ( column1 number(10) )
SQLServer
CREATE TABLE ##book_archive ( column1 int )
ASE, Access, Aurora MySQL, BigQuery, ClickHouse, CockroachDB, Databricks, DuckDB, Exasol, HSQLDB, Informix, MariaDB, MySQL, Postgres, Redshift, SQLDataWarehouse, SQLite, Snowflake, Spanner, Sybase, Trino, YugabyteDB
/* 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!