In standard SQL, a temporary table can be defined in advance to enable an empty temporary table to be created automatically when the application connects to the database. However, in Symfoware Server, a temporary table must be created when the application connects to the database by explicitly using the CREATE TABLE statement.
If the same temporary table is repeatedly created and deleted during the same session, the system table might expand, and memory usage might increase. To prevent this, specify the CREATE TABLE statement to ensure the temporary table is reused.
For example, in cases where a temporary table would be created and deleted for repeatedly executed transactions, specify the CREATE TABLE statement as shown below:
Specify "IF NOT EXISTS" to create a temporary table only if none exists when the transaction starts.
Specify "ON COMMIT DELETE ROWS" to ensure all rows are deleted when the transaction ends.
See
Refer to "SQL Commands" under "Reference" in the PostgreSQL Documentation for information on the CREATE TABLE statement.
Examples of SQL using a temporary table are shown below:
BEGIN; CREATE TEMPORARY TABLE mytable(col1 CHAR(4), col2 INTEGER) ON COMMIT DROP; (mytable processes) COMMIT;
BEGIN; CREATE TEMPORARY TABLE IF NOT EXISTS mytable(col1 CHAR(4), col2 INTEGER) ON COMMIT DELETE ROWS; (mytable processes) COMMIT;