How do I check to see if an Oracle temporary table exists? I do not see the table when querying ALL_TABLES or USER_TABLES when I know it exists.
Also, to make sure I understand temporary tables, if created with ON COMMIT DELETE ROWS, the table will always exist, but the data will be deleted when the session ends? Is a session referring to when a connection is closed?
A temporary table will be listed in
USER_TABLESif you own it and inALL_TABLESif you have privileges on the table. It will be listed inDBA_TABLESif it exists in the database but you may not have privileges to queryDBA_TABLES. If the table exists in the database but it is not inALL_TABLES, that implies that the current user does not have privileges on the temporary table.Yes, a temporary table will always exist (once it is created, of course). When you specify
ON COMMIT DELETE ROWS, the data in the temporary table will be removed when the transaction completes (either committing or rolling back). Each session will always only see the data that it has inserted into the table but when you specifyON COMMIT DELETE ROWSyou’re further limiting the time that the data exists to the current transaction.