/usr/share/doc/firebird/sql.extensions
SQL Language Extension: global temporary tables Author: Vlad Khorsun <hvlad at users.sourceforge.net> Function: Global temporary tables (GTTs) are tables with permanent metadata, stored in the system catalogue, but with temporary data. GTT's may be of two kinds - with data, persistent within lifetime of connection in which the given GTT was referenced, and with data, persistent within only during lifetime of referencing transaction. The data from different connections (transactions) are isolated from each other, but metadata of the global temporary table are shared between all connections and transactions. Syntax and rules : CREATE GLOBAL TEMPORARY TABLE ... [ON COMMIT <DELETE | PRESERVE> ROWS] Creates metadata of the temporary table in the system catalogue. Clause ON COMMIT sets the kind of temporary table: ON COMMIT PRESERVE ROWS : data of the given table after end of transaction remain in database until end of connection ON COMMIT DELETE ROWS : data of the given table are deleted from database immediately after end of transaction If optional clause ON COMMIT is not specified ON COMMIT DELETE ROWS is used by default. CREATE GLOBAL TEMPORARY TABLE - usual DDL statement and processed by the engine the same way as operator CREATE TABLE. Therefore it's impossible to create or drop GTT within stored procedure or trigger. GTT differs from permanent tables by value of RDB$RELATIONS.RDB$RELATION_TYPE : GTT with ON COMMIT PRESERVE ROWS option has value 4 in RDB$RELATION_TYPE field whereas GTT with ON COMMIT DELETE ROWS option has value of 5. See full list of values in RDB$TYPES GTT may have indexes, triggers, field level and table level constraints - as well as usual tables. All kinds of constraints between temporary and persistent tables follow the rules below: a) references between persistent and temporary tables are forbidden b) GTT with ON COMMIT PRESERVE ROWS can't have reference on GTT with ON COMMIT DELETE ROWS c) Domain constraints can't have reference on GTT. Implementation details: GTT instance (set of data rows created by and visible within given connection or transaction) is created when referenced for the first time, usually at statement prepare time. Each instance has its own private set of pages on which data and indexes are stored. Data rows and indexes have the same physical storage layout as permanent tables. When connection or transaction ends all pages of a GTT instance are released immediately (this is similar as when you do DROP TABLE but metatada remains in database of course). This is much quicker than traditional row by row delete + garbage collection of deleted record versions. DELETE triggers are not fired in this case. Note, COMMIT\ROLLBACK RETAINING preserves data of GTT with ON COMMIT DELETE ROWS. Due to bug in Firebird 2.x that data was not visible to the user application. It is fixed in Firebird 3. See also description of ClearGTTAtRetaining setting at firebird.conf. Data and index pages of all of the GTTs instances are placed in separate temporary files. Each connection has its own temporary file created when this connection first referenced some GTT. Also these temporary files are always opened with "Forced Writes = OFF" setting despite of database setting. There's no limit on number of GTT instances. If you have N transactions active simultaneously and each transaction has referenced some GTT then you'll have N GTTs instances.
.
Edit
..
Edit
README.PSQL_stack_trace.txt
Edit
README.aggregate_filter.md
Edit
README.aggregate_tracking
Edit
README.alternate_string_quoting.txt
Edit
README.autonomous_transactions.txt
Edit
README.blob_append.md
Edit
README.builtin_functions.txt
Edit
README.case
Edit
README.coalesce
Edit
README.column_type_psql.txt
Edit
README.common_table_expressions
Edit
README.context_variables
Edit
README.context_variables2
Edit
README.cumulative_roles.txt
Edit
README.current_time
Edit
README.cursor_variables.txt
Edit
README.cursors
Edit
README.data_type_results_of_aggregations.txt
Edit
README.data_types
Edit
README.db_triggers.txt
Edit
README.ddl.txt
Edit
README.ddl_access.txt
Edit
README.ddl_triggers.txt
Edit
README.default_parameters
Edit
README.derived_tables.txt
Edit
README.distinct
Edit
README.domains_psql.txt
Edit
README.exception_handling
Edit
README.execute_block
Edit
README.execute_statement
Edit
README.execute_statement2
Edit
README.explicit_locks
Edit
README.expression_indices
Edit
README.external_connections_pool
Edit
README.floating_point_types.md
Edit
README.global_temporary_tables
Edit
README.hex_literals.txt
Edit
README.identity_columns.txt
Edit
README.iif
Edit
README.isc_info_xxx
Edit
README.joins.txt
Edit
README.keywords
Edit
README.leave_labels
Edit
README.length
Edit
README.linger
Edit
README.list
Edit
README.management_statements_psql.md
Edit
README.mapping.html
Edit
README.merge.txt
Edit
README.null_value
Edit
README.nullif
Edit
README.offset_fetch.txt
Edit
README.order_by_expressions_nulls
Edit
README.packages.txt
Edit
README.plan
Edit
README.regr_functions.txt
Edit
README.returning
Edit
README.rows
Edit
README.savepoints
Edit
README.scrollable_cursors.txt
Edit
README.select_expressions
Edit
README.sequence_generators
Edit
README.set_bind.md
Edit
README.set_role
Edit
README.set_transaction.txt
Edit
README.similar_to.txt
Edit
README.sql_security.txt
Edit
README.statistical_functions.txt
Edit
README.subroutines.txt
Edit
README.substring_similar.txt
Edit
README.time_zone.md
Edit
README.trim
Edit
README.universal_triggers
Edit
README.update_or_insert
Edit
README.user_management
Edit
README.view_updates
Edit
README.window_functions.md
Edit