DECLARE GLOBAL TEMPORARY TABLE tablename (
MYDATEID date not null
) ON COMMIT PRESERVE ROWS;
As stated in the documentation, ON COMMIT PRESERVE ROWS means that the rows will be preserved when a COMMIT operation is performed.
So, if there is not explizitely COMMIT statement in my .sql-code, my table will still be exist? Or does it have something to do with "internal"-Commit, if any sql-operation is done? Like, if there is a SELECT statement in my sql-File, and after the operation of this SELECT statement, the Commit operation will be performed(implicitely).
DB2 does not have an "implicit-commit". The COMMIT must be explicitly sent to the database. This can be done by either having "Auto-Commit" turned on, or explicitly executing the COMMIT statement. How Auto-Commit is used depends on the client software being used.
What the ON COMMIT PRESERVE ROWS clause does for you, is that if a COMMIT is executed, then the contents of the temporary table will not be deleted. But anything you do to the temporary table prior to a commit will be preserved.