Skip to main content

Temporary Tables

 Temporary tables

Temporary tables data can be for a temporary period of a transaction or a session.
Temporary data for a transaction example :-


create global temporary table emp_temp
(empno number,
 ename varchar2(30),
 sal number,
 deptno number) on commit delete rows;

  

Insert records to test data for a transaction:-

insert into emp_temp values ( 1, 'krishna', 1000, 10);
insert into emp_temp values ( 2, 'Raghu', 1000, 10);
insert into emp_temp values ( 3, 'Sachin', 1000, 10);
insert into emp_temp values ( 4, 'Amit', 1000, 10);


Verifying table data before deleting with a commit command :-

select * from emp_temp;

Issuing commit to delete the records of the temporary table:-

commit;

Verifying table data after deleting with a commit command :-

select * from emp_temp;

no rows selected



Temporary data for a session example :-

Drop table emp_temp;

create global temporary table emp_temp
(empno number,
 ename varchar2(30),
 sal number,
 deptno number) on commit preserve rows;

  

Insert records to test data for a transaction:-


insert into emp_temp values ( 1, 'krishna', 1000, 10);
insert into emp_temp values ( 2, 'Raghu', 1000, 10);
insert into emp_temp values ( 3, 'Sachin', 1000, 10);
insert into emp_temp values ( 4, 'Amit', 1000, 10);


Verifying table data that should delete after ending a session :-

select * from emp_temp;


Issuing disc command  to end your session and delete the records of the temporary table:-

disc;

Connect back to check if the records are available:-

select * from emp_temp;

no rows selected


Comments

Sahaja said…
Step by step process is mentioned which is very helpful for beginners.
Malavieka said…
Each step is explained very well.
Thank you.
Well explained
thank you sir
Samreen khan said…
Very well explained
Thankyou Sir
This comment has been removed by the author.
AMISHA GUPTA said…
Clear explanation for beginners.
Thank you
sindhuja said…
each step was explained clearly and very useful for beginners
Rinitha Jose said…
Very helpful. Easy to understand with the example provided.
Anonymous said…
Easy to learn for beginners ..Gud Explanation sir
Thank you.
Unknown said…
Very helpful Content for beginners.
Thank you sir....
bhavya said…
Well explained sir
thankyou
Very nicely explained. Thankyou for sharing!
bhavana said…
good and easy explanation
Well explained! Thankyou sir
Shantha said…
Very well explained and easy to understand. Thank you.
Manasa said…
Easy to understand and very helpful for beginners
sayani said…
The topic is explained clearly step by step. thank you, sir.
Unknown said…
Explained very well sir!
Tanya said…
Nicely explained. Thank you sir!
Unknown said…
Very helpful content for beginners.
Thank you sir....
Very well explained.
Thank you
Pranav said…
easy to understand nicely explained

Popular posts from this blog

PL / SQL practice programs

  PL / SQL  practice programs 1. Write a program to print the following format WELCOME TO PL/SQL PROGRAMMING   BEGIN   DBMS_OUTPUT.PUT_LINE('WELCOME   TO   PL/SQL   PROGRAMMING'); END; /   2. Write a program to print the numbers from 1 to 100   DECLARE N NUMBER(3):=1; V VARCHAR2(1000); BEGIN WHILE N <=1000 LOOP V:=V||''||N; N:=N+1; END LOOP; DBMS_OUTPUT.PUT_LINE(V); END; / 3. write a program to print the even numbers from 1 to 100 DECLARE N NUMBER(3):=0; BEGIN WHILE N <=100 LOOP N:=N+2; DBMS_OUTPUT.PUT_LINE(N); END LOOP; END; / 4. Write a program to print the odd numbers from 1 to 100 DECLARE N NUMBER(3):=1; BEGIN WHILE N <=100 LOOP N:=N+2; DBMS_OUTPUT.PUT_LINE(N); END LOOP; END; / 5. write a program for multiplication table DECLARE A NUMBER(2):=&A; B   NUMBER(2):=1; C ...

RDBMS MINI PROJECT

  Capgemini class room training.   RDBMS MINI PROJECT ( SPRINT ) LIBRARY MANAGEMENT SYSTEM   Table of Contents Serial No. Topic Name Content Page No. 1.   Introduction 1.1 Setup checklist for mini project 3     1.2 Instructions 3 2.   Problem statement   2.1 Objective 4     2.2 Abstract of the project 4     2.3 Functional components of the project 4     2.4 Technology used 5 3.   Implementation in RDBMS LOT 3.1 Guidelines on the functionality to be built 6 4.   Evaluation 4.1 Evaluation 7   ...
  COGNIZANT Freshers   ORACLE Training @  Pune 2014 What is Embedded SQL in DBMS?  When we talk about embedded SQL, it can be understood as small SQL queries put into high-level languages to get meaningful outputs. While embedding SQL queries into other high-level languages, we need to make sure that we have a working database connector on our system. By using the connectors we can easily run SQL queries on the existing databases in our RDBMS or we can even create new ones. Let us now dive deep into the embedded SQL concepts and learn more about it. What is Embedded SQL? As we have seen in our previous tutorials, SQL is known as the Structured Query Language. It is the language that we use to perform operations and transactions on the databases. When we talk about industry-level applications we need properly connected systems which could draw data from the database and present to the user. In such cases, the embedded SQL comes to our rescue. We embed SQL queries...