GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  PL/SQL
Go To First  |  Previous Question  |  Next Question 
 PL/SQL  |  Question 211 of 241    Print  
Global Temporary Table
What is Global temporary table? and what are the benefits of it?


  
Total Answers and Comments: 3 Last Update: October 26, 2009     Asked by: ravishing_sid 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: jannaat
 
GLOBAL TEMPORARY TABLE statement defines a temporary table for the current session. The declared temporary table description does not appear in the system catalog. It is not persistent and cannot be shared with other sessions. Each session that defines a declared global temporary table of the same name has its own unique description of the temporary table. When the session terminates, the rows of the table are deleted, and the description of the temporary table is dropped.

Above answer was rated as good by the following members:
nagarajkv, harit79, johnjerry
April 29, 2008 02:14:25   #1  
jannaat Member Since: April 2008   Contribution: 7    

RE: Global Temporary Table
GLOBAL TEMPORARY TABLE statement defines a temporary table for the current session. The declared temporary table description does not appear in the system catalog. It is not persistent and cannot be shared with other sessions. Each session that defines a declared global temporary table of the same name has its own unique description of the temporary table. When the session terminates the rows of the table are deleted and the description of the temporary table is dropped.
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
November 03, 2008 09:38:35   #2  
taya_ronak Member Since: November 2008   Contribution: 8    

RE: Global Temporary Table
Global temporary table is kind of temporary table managed by system. it'll keep in temporary tablespace till the session remain. there are two methods available i.e.

1) create global temporary table t1 on commit delete rows.
with this option table t1 data will be lost whenever commit will be issued by user.

2) create global temporary table t1 on commit preserve rows.
with this option table t1 data will be lost whenever session is lost.

after deletion we do not need to give any storage management command because global temporary tables are system managed and after deletion of data space which was occupied by table are ready to allocate for other use.

 
Is this answer useful? Yes | NoAnswer is useful 2   Answer is not useful 0Overall Rating: +2    
October 24, 2009 09:38:31   #3  
vanishavadlya Member Since: October 2009   Contribution: 3    

RE: Global Temporary Table

The data in a global temporary table is private such that data inserted by a session can only be accessed by that session. The session-specific rows in a global temporary table can be preserved for the whole session or just for the current transaction. The ON COMMIT DELETE ROWS clause indicates that the data should be deleted at the end of the transaction.

CREATE GLOBAL TEMPORARY TABLE my_temp_table ( column1 NUMBER column2 NUMBER ) ON COMMIT DELETE ROWS;

In contrast the ON COMMIT PRESERVE ROWS clause indicates that rows should be preserved until the end of the session.

CREATE GLOBAL TEMPORARY TABLE my_temp_table ( column1 NUMBER column2 NUMBER ) ON COMMIT PRESERVE ROWS;

Miscellaneous Features

  • If the TRUNCATE statement is issued against a temporary table only the session specific data is trucated. There is no affect on the data of other sessions.
  • Data in temporary tables is automatically delete at the end of the database session even if it ends abnormally.
  • Indexes can be created on temporary tables. The content of the index and the scope of the index is that same as the database session.
  • Views can be created against temporary tables and combinations of temporary and permanent tables.
  • Temporary tables can have triggers associated with them.
  • Export and Import utilities can be used to transfer the table definitions but no data rows are processed.
  • There are a number of restrictions related to temporary tables but these are version specific.

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape