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

 
 Home
 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
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

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

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Global temporary table example

Oracle Database Tips by Donald BurlesonMarch 3, 2015

Question:  I need an example of how a global temporary table works.  How does a global temporary table differs from a traditional temporary table or a WITH clause?   I need a working example of a global temporary table.  Do you need to drop the Global temporary table after each use?

Answer:  When using a global temporary table you need only define the table once for the entire schema and then any user can insert directly into the table without the need to re-create the global temporary table.
 
drop table t1;
create table
   t1
as
select sum(quantity) all_sales from stores;

Instead, a global temporary table does not required that the table be dropped and re-created and the global temporary tables are shared, such that each user gets a local copy of their rows, using the common definition. 

create global temporary table
   sum_quantity
  (sum_qty number);

Once created, everyone shares the table definition and rows are private to each session.  Here is an example of using a global temporary table:


SQL> insert into sum_quantity
2 (select sum(qty) from sales);

Note that the rows disappear after the SQL statement has completed, so that a GTT can be used over-and-over without redoing the table.

SQL> select * from sum_quantity;

SUM_QTY
----------
499

SQL> commit;

Commit complete.

SQL> select * from sum_quantity;

no rows selected 

 

 
Get the Complete
Oracle SQL Tuning Information 

The landmark book "Advanced Oracle SQL Tuning  The Definitive Reference"  is filled with valuable information on Oracle SQL Tuning. This book includes scripts and tools to hypercharge Oracle 11g performance and you can buy it for 30% off directly from the publisher.

 

 

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