Oracle Temporary Table: Create and Add Data

To create a temporary table and add content in Oracle, you can follow these steps:

  1. Create a temporary table.
CREATE GLOBAL TEMPORARY TABLE temp_table (
  column1 datatype1,
  column2 datatype2,
  ...
) ON COMMIT DELETE ROWS;

In the example above, temp_table is the name of the temporary table, datatype1, datatype2, etc. are the data types of the columns. The keyword ON COMMIT DELETE ROWS indicates that all rows in the temporary table will be deleted when the transaction is committed.

  1. Add content to the temporary table.
INSERT INTO temp_table (column1, column2, ...)
VALUES (value1, value2, ...);

In the example above, values are inserted into columns such as column1 and column2 in the temporary table temp_table.

  1. Utilize temporary tables:
SELECT * FROM temp_table;

You can query and manipulate the data in the temporary table just like a regular table.

Please note that temporary tables will be automatically deleted at the end of the session, so there is no need to manually delete them.

bannerAds