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

Applies to ✅ 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 policy 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 TEMPORARY if it's supported by a dialect
  • LOCAL TEMPORARY otherwise
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, Derby, DuckDB, Exasol, HSQLDB, Informix, MariaDB, MySQL, Postgres, Redshift, SQLDataWarehouse, SQLite, Snowflake, 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!

The jOOQ Logo