Creating Global Temporary Table
Here is the syntax for creating a GTT is similar to a regular table but includes the ON COMMIT
clause to define its behavior.
Example:
CREATE GLOBAL TEMPORARY TABLE sales_gtt (
sale_number NUMBER,
product_name VARCHAR2(100),
sale_date DATE
) ON COMMIT DELETE ROWS; -- Data deleted at the end of each transaction
Alternatively, for session-specific data retention:
CREATE GLOBAL TEMPORARY TABLE temp_logs (
log_id NUMBER,
log_message VARCHAR2(255)
) ON COMMIT PRESERVE ROWS; -- Data persists until the session ends