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
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
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
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
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.
try running the GTT yourself and see of the table
- 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$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:
For full scripts, download our
Oracle script collection
Oracle Training from Don Burleson
The best on site
training classes" are just a phone call away! You can get personalized Oracle training by Donald Burleson, right at your shop!
Burleson is the American Team
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
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
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
and include the URL for the page.
Copyright © 1996 - 2017
All rights reserved by
is the registered trademark of Oracle Corporation.
Remote Emergency Support provided by