PRESERVE is a reserved word defined in the SQL Standard and implemented by several databases to indicate that something should be retained instead of discarded or reformatted. The most common appearance is in the clause ON COMMIT PRESERVE ROWS when creating a temporary table. In that context, PRESERVE instructs the database engine to keep the rows that were inserted into the temporary table even after a COMMIT statement is issued. The rows remain visible for the lifetime of the session and are deleted automatically only when the session ends or the temporary table is dropped.Other vendor-specific uses exist (for example, PRESERVE BLANKS in Db2 and PRESERVE ROWS in Oracle materialized views), but they share the same semantic idea: do not remove or collapse the referenced data. Because PRESERVE is not a standalone statement, it must appear inside a larger DDL or DML command. Attempting to run PRESERVE by itself results in a syntax error.
ON COMMIT, DELETE ROWS, TEMPORARY TABLE, SESSION SCOPE, GLOBAL TEMPORARY TABLE
SQL:1999 (temporary table definition)
PRESERVE keeps rows in the temporary table after each COMMIT, while DELETE removes them automatically. Choose PRESERVE when you need the data for multiple transactions.
No. The table is dropped automatically at session end unless you explicitly execute DROP TABLE.
Yes. In Oracle and Standard SQL you may write CREATE GLOBAL TEMPORARY TABLE ... ON COMMIT PRESERVE ROWS; to make the table visible to all sessions but keep each session’s data separate.
Your database dialect might not support the PRESERVE clause, or you placed it outside the ON COMMIT clause. Verify that the command is supported and that PRESERVE appears immediately after ON COMMIT.