Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 







  global temporary table troubleshooting debug tips

Oracle Database Tips by Donald BurlesonMarch 26, 2015

Question:  How can I perform global temporary table troubleshooting?  I cannot see the rows in other people's GTT's, and I need to understand how to debug  my global temporary tables.  I need to see all of the rows for the GTT, even by users in other sessions.

Answer:  The first step in troubleshooting a GTT is to understand that the global temporary table is just a data dictionary definition and the data is stored in the users area of the PGA or the TEMP tablespace.  Note that all global temporary table rows go directly to the PGA work area before they spill out into the TEMP tablespace, and Oracle does not create a temporary segment if an operation can be performed in memory. However, if PGA RAM allocation is exhausted, then the database automatically allocates a temporary segment on disk.

For small RAM usage of GTT rows, you can use these scripts to see RAM usage.

For large global temporary tables, the data can be seen when you display TEMP tablespace contents.  The Oracle docs say:

"Oracle Database does not create a temporary segment if an operation can be performed in memory. However, if memory use is not possible, then the database automatically allocates a temporary segment on disk."

A global temporary table is very reliable and so long as you have enough space (PGA and TEMP tablespace) then the GTT should create the data just fine.  I have never seen a GTT fail to create data for each users session unless there is a TEMP tablespace issue.

  • First, try running the GTT yourself and see of the table data appears.

  • Second, change the GTT to a regular heap table and make it unique by appending the date/time stamp to the table name.  This way, you can observe the tables as permanent tables.
  • Yet another way to see what data is going into a temporary table without recreating the GTT manually and using it in your session (your first debugging step) it is to add a trigger (in your TEST instance!) on the global temporary table. 

This trigger inserts the rows into a non-temporary copy of the work table using PRAGMA AUTONOMOUS_TRANSACTION.  Then you can commit the data table without affecting the current session. When you're done troubleshooting the GTT, you drop the trigger and your copy of the table.

  • You can also not use a GTT and store the transient data as a PL/SQL type or a PL/SQL collection.  This troubleshooting and debugging technique requires extensive coding changes.

Note that you cannot always see others GTT data because it is first stored in the PGA RAM (per the memory_target parameter) and later in the TEMP tablespace. 

   v$tempseg_usage a
   v$session b on a.session_num = b.serial#;

You can also query the v$sort_usage view to see how temp tablespace objects map to sessions. With the aid of Oracle Technical Support (MOSC) you can then hack-in users executing sessions and see their data.  Open an SR on MOSC for details on this sensitive procedure.  Here is how to get the names and session numbers:

   v$statname   a,
   v$sesstat    b,
   v$session    s,
   v$sort_usage su

For full scripts, download our Oracle script collection

Oracle Training from Don Burleson 

The best on site "Oracle training classes" are just a phone call away! You can get personalized Oracle training by Donald Burleson, right at your shop!

Oracle training



Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.



Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster