Global temporary tables are temporary tables visible to all sessions. The contents (and even the table depending on the DBMS) are automatically removed when the connection is closed.
Global temporary tables are visible to all sessions.
Syntax
For SQL Server
prefix of global temporary table names with a double number sign:
##table_name
For Firebird, Oracle and PostgreSQL
create global temporary table table_name (....);
Lifetime
For SQL Server
Global temporary tables are automatically dropped when the session that created the table ends and all other tasks have stopped referencing them. The association between a task and a table is maintained only for the life of a single Transact-SQL statement. This means that a global temporary table is dropped at the completion of the last Transact-SQL statement that was actively referencing the table when the creating session ended.
For Firebird, Oracle and PostgreSQL
Global temporary tables are created once and will exist until they are dropped using a DROP TABLE
. The data in the GTT however is automatically removed when the session disconnects or when the transaction is committed.