0% found this document useful (0 votes)
33 views5 pages

Re: What Are Global Temporary Tables Answer

Global temporary tables are session-dependent tables that can be used for temporary storage, calculations, or sorting. The data in a global temporary table is not written to the database and only exists for the duration of the session. However, the table structure remains even after the session ends. Multiple sessions can use the same global temporary table simultaneously without interfering with each other's data. Global temporary tables are useful when data needs to be cached and accessed repeatedly within a session, such as for aggregating results.

Uploaded by

pakeera1923
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views5 pages

Re: What Are Global Temporary Tables Answer

Global temporary tables are session-dependent tables that can be used for temporary storage, calculations, or sorting. The data in a global temporary table is not written to the database and only exists for the duration of the session. However, the table structure remains even after the session ends. Multiple sessions can use the same global temporary table simultaneously without interfering with each other's data. Global temporary tables are useful when data needs to be cached and accessed repeatedly within a session, such as for aggregating results.

Uploaded by

pakeera1923
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Re: What are Global Temporary tables

Answer Global Temporary tables are session dependant


# 1 tables which
could be used as temporary storage for
calculations, sorting
etc. What I mean by Session dependant is, the
data being
stored in the Global Temporary table is not
written into the
database or stored anywhere. Once the session
ends (in which
the Global Temporary table is used), the data
also vanishes.

However the structure would still be available


even after
the Session is logged out. Also, the structure
is available
to other sessions even when one session is
using it, but not
the data. i.e multiple sessions could use the
same Global
Temporary table without interfering the data.
Each session
could insert/update/delete their own data into
the same
Global Temporary table as if the table is
available to only
that session. Any data inserted in one session
is not
available to another.

Now, why do we need Global Temporary tables?


Well, imagine a
requirement where you need to fetch some data
from the
database, do some kind of calculations,
aggregations and
provide the Result Set (many records) to a
Front End. Again,
in the Front End, you need to fetch the Result
set may
times, for some purpose. Then you could make
use of the
Global Temporary table. Until the user gets
disconnected
from that Database session, the data is
available for him in
the memory.
Re: What are Nested Tables? How will u delete 5 rows from Nested Tables
Answer CREATE Or Replace TYPE AddressType AS OBJECT (
street VARCHAR2(15),
#1 city VARCHAR2(15),
state CHAR(2),
zip VARCHAR2(5)
);

CREATE Or Replace TYPE


nested_table_AddressType AS TABLE OF
AddressType;

CREATE TABLE employee (


id INTEGER PRIMARY KEY,
first_name VARCHAR2(10),
last_name VARCHAR2(10),
addresses nested_table_AddressType
)
NESTED TABLE
addresses
STORE AS
nested_addresses;

INSERT INTO employee VALUES (


1, 'Steve', 'Brown',
nested_table_AddressType(
AddressType('2 Ave', 'City', 'MA',
'12345'),
AddressType('4 Ave', 'City', 'CA',
'54321')
)
);

DELETE FROM TABLE (


SELECT addresses FROM employee WHERE id
= 1
) addr
WHERE
VALUE(addr) = AddressType(
'4 Ave', 'City', 'CA', '54321'
);

ora816 SamSQL :> declare

2 Procedure InsertInTest_Table_B

3 is

4 BEGIN

5 INSERT into Test_Table_B(x) values (1);

6 Commit;
7 END ;

8 BEGIN

9 INSERT INTO Test_Table_A(x) values (123);

10 InsertInTest_Table_B;

11 Rollback;

12 END;

13 /

PL/SQL procedure successfully completed.

ora816 SamSQL :> Select * from Test_Table_A;

----------

123

ora816 SamSQL :> Select * from Test_Table_B;

----------

Notice in above pl/sql COMMIT at line no 6 , commits the transaction at line-no 5


and line-no 9. The Rollback at line-no 11 actually did nothing. Commit/ROLLBACK
at nested transactions will commit/rollback all other DML transaction before that.
PRAGMA AUTONOMOUS_TRANSACTION override this behavior.

Let us the see the following example with PRAGMA


AUTONOMOUS_TRANSACTION.

 
ora816 SamSQL :> declare

2 Procedure InsertInTest_Table_B

3 is

4 PRAGMA AUTONOMOUS_TRANSACTION;

5 BEGIN

6 INSERT into Test_Table_B(x) values (1);

7 Commit;

8 END ;

9 BEGIN

10 INSERT INTO Test_Table_A(x) values (123);

11 InsertInTest_Table_B;

12 Rollback;

13 END;

14 /

PL/SQL procedure successfully completed.

ora816 SamSQL :> Select * from Test_Table_A;

no rows selected

ora816 SamSQL :> Select * from Test_Table_B;

----------

1
 

With PRAGMA AUTONOMOUS_TRANSACTION , the transaction state maintained


independently . Commit/Rollback of nested transaction will no effect the other
transaction. It is advisable to increase the value of TRANSACTIONS parameter in
the INIT parameter file to allow for the extra concurrent transaction

11G

http://books.google.co.in/books?id=ot7sS-
xC5AYC&pg=PA267&lpg=PA267&dq=different+types+of+procedures+in+realtime+for+oracle&source=
bl&ots=gnT8snRnx4&sig=ZhnJmBibbc-
Tv7aCd_AxCl6K9Ls&hl=en&ei=5k60TLG5BYq3cMDcxLQI&sa=X&oi=book_result&ct=result&resnum=7
&ved=0CDEQ6AEwBg#v=onepage&q&f=false

You might also like