Oracle temporary tables

Hi ,
we have a application for transfering data approx 1 million records from one schema to another. the data is first inserted into a table temporarily and after all the data is transfered the data is manually deleted from this table.
we are planning to replace this table with Oracle Temporary table. Can you please let us know if this would increase the performance and why???
Thanks & Regards
Saroj

In theory it should, but you won't know whether the difference is going to be noticeable until you try.
Oracle has to do much less work with global temporary tables. It knows no other sessions will be using the data so it does not need to bother with rollback segments or locks. It also does not bother with redo because there will not be a need to recover.

Similar Messages

  • TopLink, use of Oracle Temporary tables

    A project using TopLink has the following questions. Could someone help answer them?
    Does TopLink support the use of Oracle Temporary tables?
    Is there any recommendation regarding the two possible ways of setting them up, see below:
    ON COMMIT Setting Description DELETE ROWS This creates a temporary table that is transaction specific. A session becomes bound to the temporary table with a transactions first insert into the table. The binding goes away at the end of the transaction. The database truncates the table (delete all rows) after each commit.
    PRESERVE ROWS This creates a temporary table that is session specific. A session gets bound to the temporary table with the first insert into the table in the session. This binding goes away at the end of the session or by issuing a TRUNCATE of the table in the session. The database truncates the table when you terminate the session.
    We appreciate your assistance.
    Haiwei

    Haiwei,
    TopLink has no explicit support for temporary tables but it should be possible. It is tough to answer your question since it really depends upon connection and transaction management for either case. What is your planned configuration TopLink with respect to external versus internal connection pooling as well as the JTA TX management.
    I believe you are deploying your applications within WebSphere but would just like to confirm that you are using WAS data sources and transaction management.
    Doug

  • Need help recreating this in Oracle (Temporary Table and a Cursor)

    Hey all,
    My client has asked me to see if it's possible to move his SQL Queries into Oracle, and then move EVERYTHING off of MSSQL into this new oracle environment. The problem is, I wrote the entire MSSQL system, and i know nothing about Oracle.
    Basically, I need some examples. I have been stumbling around Oracle for about a year now, so i'm 'somewhat' familiar with it.
    Basically, i'm going to create a script/stored procedure that will first:
    Create and define a temporary table that is used when the script/proc is called.
    Then, thru cursors, i'm going to add a bunch of lines to it.
    Finally, i'm going to Run a select statement against the temporary table we created.
    Now, I can't create a table on the server, as the production environment will not allow it, so i need to be able to create this virtually inside the script, and then it automatically self destructs at the end of the script.
    If anyone knows if this is possible, please post me a few links to examples, or just lay down the code to get the temprary table made.
    We're using TOAD as the interface.
    Thanks,
    Dan

    Thank you for the warm welcome.
    The SQL looks something like this:
    (Before you get lost in the code, this is an abreviation of the code, but every function is represented. This will also work in TOAD Script? I'm most worried about the use of how a Table is declared in Oracle, as i've seen many different versions of how to do this. Thanks)
    ~Dan
    Declare @AREA nvarchar(50)
    Declare @tmpTable Table (
         [AC_PROPERTY_ID] [INT] NULL,
         [PROPNUM] [nvarchar](50) NULL,
         [SORT_ORDER] [INT] NULL,
         [IS_TOTAL] [BIT] NULL,
         [FIELD] [nvarchar](200) NULL,
    [AREA] [nvarchar](200) NULL,
         [ENG] [nvarchar](200) NULL,
         [RSV_CAT] [nvarchar](200) NULL,
         [WELL_NAME] [nvarchar](200) NULL,
         [SHORTS_PROGRAM] [nvarchar](15) NULL,
         [SHORT_MO] [nvarchar](6) NULL,
         [SHORTS_YR] [nvarchar](6) NULL,
         [SHORTS_DESC] [nvarchar](100) NULL)
    Insert Into @tmpTable ([AC_PROPERTY_ID],[PROPNUM],[FIELD],[AREA],[ENG],[RSV_CAT],[WELL_NAME],[SHORTS_PROGRAM],[SHORT_MO],[SHORTS_YR],[SHORTS_DESC])
    Select AC_PROPERTY_ID],[PROPNUM],[FIELD],[AREA],[ENG],[RSV_CAT],[WELL_NAME],[SHORTS_PROGRAM],[SHORT_MO],[SHORTS_YR],[SHORTS_DESC] from dbo.someoldtablenameimadeup where propnum>1000
         DECLARE idcursor cursor
         FOR
         Select Distinct AREA
         from @tmpTable
         Open idcursor
         Fetch Next from idcursor into @AREA
              While (@@FETCH_STATUS <> -1)
                   BEGIN
                   IF (@@FETCH_STATUS <> -2)
                        <Do stuff for each record in the cursor>
              FETCH NEXT FROM idcursor INTO @AREA
              END
              CLOSE idcursor
              DEALLOCATE idcursor

  • How to use Oracle temporary table and verify if it exists

    1. I got two errors on the following code.
    ORA-06550: line 13, column 4:
    PLS-00428: an INTO clause is expected in this SELECT statement
    ORA-06550: line 17, column 3:
    PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
    2. Can I include this code in the create view statement?
    Thanks ahead, I am new to oracle dev world.
    ===========================================================
    DECLARE
    l_count NUMBER;
    BEGIN
    select count(*)
    into l_count
    from all_tables
    where table_name like 'TEMP_SHOW_STAFF_2%';
    if l_count > 0 then
    select * from TEMP_SHOW_STAFF_2;
    else
    create global temporary table TEMP_SHOW_STAFF_2
    (employee_id Number,
    last_name varchar(10),
    first_name varchar(10),
    salary_amount varchar(10))
    on COMMIT delete rows;
    end if;
    END;

    The PL/SQL User's Guide will have much more information, but as a quick example (new_dept is an empty table with the same structure as the DEPT table in the SCOTT schema).
      1  declare
      2    -- Create the type & declare a variable of that type
      3    type dept_arr_typ is table of dept%rowtype;
      4    dept_arr dept_arr_typ;
      5  begin
      6    -- Populate the type in memory
      7    select *
      8      bulk collect into dept_arr
      9      from dept;
    10    -- Manipulate the data
    11    for i in 1..dept_arr.count
    12    loop
    13      select 'foo'
    14        into dept_arr(i).dname
    15        from dual;
    16    end loop;
    17    -- Write the data back
    18    for i in 1..dept_arr.count
    19    loop
    20      insert into new_dept( deptno, dname, loc )
    21        values( dept_arr(i).deptno, dept_arr(i).dname, dept_arr(i).loc );
    22    end loop;
    23* end;
    SCOTT @ nx102 Local> /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.01
    SCOTT @ nx102 Local> select * from new_dept;
        DEPTNO DNAME          LOC
            10 foo            NEW YORK
            20 foo            DALLAS
            30 foo            CHICAGO
            40 foo            BOSTONOf course, for this sort of thing, we could do everything in a single SQL statement
    INSERT INTO new_dept( deptno, dname, loc )
      SELECT deptno, 'foo', loc
        FROM dept;Collections can be handy if you need to apply a bit more conditional logic, though.
    Justin

  • Can oracle temporary tables be used with distributed transactions?

    Hello,
    Does anybody know if temporary tables are supported with distributed transactions?
    We use a temporary table to store query results and see no problems when the JDBC driver (Type 2 or Type 4) is used with local transactions. The temporary tables are set for transaction-level data persistence (delete rows on commit).
    When we switch to JDBC/XA driver we occasionally get ORA-14450 error (java.sql.SQLException: ORA-14450: attempt to access a transactional temp table already in use).
    Many thanks...

    I have been able to use temporary tables on remote databases, so I don't think that it is forbidden. Of course, I'm not using JDBC so that might be a problem.
    The other thing that occurs to me is that you are doing something other than DML with the table e.g. trying to drop it. If that is the case you should re-read the documentation and remind yourself of the purpose of temporary tables.
    Cheers, APC

  • Temporary Tables in Oracle

    Hi all,
    I am developing a .net application withe back end being oracle 10g. previously i worked with sql server 2005,2008 and i am new to oracle.
    i am working on a complex query which requiries, temporary table inside the procedure. In sql server easy to create and drop the temp table inside the proc.
    Can I use a Transaction specific GTT to store and process the temporary data inside my procedure??? My web application gets connected to the database through a one username and password. Since being a web applicatioin multiple users will execute the procedure at the same time, logged under the same username and password...
    I know its a coomon question, but i need it urgently..
    its very complicated to use WITH SELCT or inline views etc...
    Thank you,
    Kris.

    I know its a coomon question, but i need it urgently..If you know it is a common question then you should know the common answer. But let's rehearse it one more time.
    In Oracle temporary tables are permanent objects. It is only the data in them which is temporary. So for your scenario you shoudl have the DBA create the table once, like any other table.
    The trick with temporary tables is that each session sees its own data and nothing else. So your procedure can populate the table with data, process it and return it without a hitch.
    Since being a web applicatioin multiple users will execute the procedure at the same time, logged under the same username and password...Doesn't matter: the view of the data is controlled by session. So you haven't got a problem providing the table is populated and the resultset returned within a single call.
    its very complicated to use WITH SELCT or inline views etc...Yes it is hard. Fortunately CPUs keep getting more powerful and bandwidth keeps getting cheaper, so our systems continue to cope with the increasing amount of suck-y code being thrown at them. Isn't Moore's Law wonderful :)
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • 8i Temporary Tables

    Using the Workbench to convert a Sybase 11 application to 8i, I've seen all the Oracle temporary tables created as "... on commit preserve rows". But we want the temps to only have transaction duration rather than session. Is there any way to tweak the tool to create temporary tables as "... on commit delete rows"?

    I had used the Migration Workbench against
    MS SQL Server 7.0. to migrate to Oracle 8.1.6.
    All the temp tables created in T-SQL stored
    procedures where converted in permanent tables.
    So not even the Oracle 8i temp tables session
    based were created as clamined by the author
    of this thread.
    My question is there a option to create temp tables (session based) for all the temp tables created via T-SQL.

  • Problem with global temporary table in Oracle 10g

    Hi All,
    I face a peculiar problem in Oracle 10g with respect to Global temporary table.
    Have Oracle 10g version in Production and 11g version in UAT.
    Table_
    create global temporary table TT_TEMPGPSMANUAL
      Col_1    VARCHAR2(50),
      Col_2    VARCHAR2(500),
      Col_3    VARCHAR2(50),
      Col_4    VARCHAR2(50),
      Col_5    VARCHAR2(15),
      Col_6    VARCHAR2(20),
      Col_7    VARCHAR2(250),
      Col_8    VARCHAR2(20),
      Col_9    VARCHAR2(15),
      Col_10   VARCHAR2(20),
      Flag     NUMBER,
      Col_11   INTEGER,
      Col_12   VARCHAR2(50)
    on commit preserve rows;So this should preserve the rows inserted into this table until the session ends.
    Have a webpage in front-end where in turn, it opens another page (session is carried through) and a few rows will be inserted to this table from the webpage (through a function) on submit and the current page will be closed.
    From the parent page, if I open the sub-page data inserted in the temporary table are held and displayed (another function to fetch the values in the Global Temp table).
    The Problem in Oracle 10g (Production) is, this is not happening properly. When I close and open the sub-page, not every time I get the data stored i.e if I close and open the page 10 times, atelast 4 times the data is missed in the page (I am not getting values from temp table) randomly.
    But this does not happen in UAT (which has Oracle 11g installed) as I get the data in the webpage consistently. After passing UAT, when we rolled out to Prod, getting this issue which we are unable to get what could be the reason.
    It is very hard to debug using GTT dynamically in prod. It takes time to get Oracle 11g installed in Prod.
    Can anyone suggest?
    Regards
    Deep

    935195 wrote:
    Also, I am opening the sub-page from the parent page (through a hyperlink). Then in this case, Would session will be changed from parent to subpage? (I am not aware exactly and have the impression that, as the second page is a child, I guess it would take the same session).I'm not sure what "sub-page" or "parent page" means to you. If you're just linking from one page to another, "parent" and "child" don't really make sense since page A links to page B and B links to A quite frequently.
    Assuming that you have to log in to access the site, it is likely that the two pages share the same middle tier application session. It is unlikely that the middle tier would hold the database session from the first request open waiting to see if the user eventually requested the second page. It is theoretically possible that you could code your middle tier this way but it is extremely unlikely that you would want to do so for a variety of reasons. So, when you say "would [the] session ... be changed", it is likely that the application session would be the same for both calls but that the database session would be different.
    Justin

  • Are global temporary tables in Oracle 10.2 behaving differently?

    My procedure is creating and inserting data into a Global Temporary Table (on commit data is preserved). I am running this procedure in two different environments.
    The first environment is running under Oracle 10.2 and after the procedure runs successfully I can not see any data inserted in the GTT.
    When I run the very same procedure in the second environment which runs under Oracle 9.2, it works fine, runs successfully and I can see all rows inserted in the GTT.
    Can someone explain this? What should I do differently in the Oracle 10.2? Any thoughts?
    Thank you very much.

    Hi,
    The following TEMPORARY table is created with the attribute, ON COMMIT DELETE ROWS. This allows an application to load registration entries into the global temporary table and manipulate that data with SQL statements. The data is deleted upon each commit with the clause ON COMMIT DELETE ROWS.
    CREATE GLOBAL TEMPORARY TABLE student_reg_entries
    student_name VARCHAR2(30),
    reg_entries reg_entry_varray_type
    ) ON COMMIT DELETE ROWS;
    Replace ON COMMIT DELETE ROWS with ON COMMIT PRESERVE ROWS to retain temporary table data throughout the database session, regardless of any commits made during that session.
    The following illustrates a PL/SQL block that populates this temporary table with two classes each for two students. It makes no difference how many other applications are currently using this temporary global table for similar purposes. For the code below, two rows are inserted, then a COMMIT, after which a SELECT shows that the table is empty.
    DECLARE
    classes_to_take reg_entry_varray_type :=
    reg_entry_varray_type();
    BEGIN
    classes_to_take := reg_entry_varray_type(
    reg_entry('CS101', 'C' ),
    reg_entry('HST310', 'C' ));
    INSERT INTO student_reg_entries VALUES
    ('John', classes_to_take);
    classes_to_take := reg_entry_varray_type(
    reg_entry('ENG102', 'C' ),
    reg_entry('BIO201', 'C' ));
    INSERT INTO student_reg_entries VALUES
    ('Mary', classes_to_take);
    END;
    This next SELECT returns two rows:
    SQL> SELECT * FROM student_reg_entries;
    Row 1:
    John
    REG_ENTRY_VARRAY_TYPE
    (REG_ENTRY('CS101','C'), REG_ENTRY('HST310','C'))
    Row 2:
    Mary
    REG_ENTRY_VARRAY_TYPE
    (REG_ENTRY('ENG102','C'), REG_ENTRY('BIO201','C'))
    A COMMIT automatically deletes rows making the table available for the next session transaction.
    SQL> COMMIT;
    SQL> SELECT * from student_reg_entries;
    no rows selected
    The full information about this article is in the link I post before, I'm just showing this extract of the article because some people don't like to read links....
    Cheers,
    Francisco Munoz Alvarez
    http://www.oraclenz.com

  • Implementing "Temporary Tables" in Oracle after migrating from SQL Server

    Hello,
    Some stored procedures referencing temporary tables in SQL Server were migrated to Oracle. In the Oracle DB, these stored procedures are invalid. In a bid to make them valid, I created the referenced temporary tables in my Oracle DB, via SQL*PLUS having logged into the database as the appropriate user. And when I query the user_tables view, I see the temporary tables that I created. Thereafter, when I compile the stored procedures, I still get the message: PL/SQL: ORA-00942: table or view does not exist. And the stored procedures remain invalid. Pls,what do I do ?
    Thanks for your cooperation

    Chux,
    The Migration Workbench should have created all the necessary temporary tables as part of the process to convert the stored procedures. Can you post the example part of the T/SQL stored procedure and what we converted it to?
    Our support for Temporary Tables is discussed in our reference guide.
    http://download-west.oracle.com/docs/html/B10254_01/ch5.htm#1026115
    Donal

  • Oracle Temporary/Memory table

    Hi Friends,
    Can oracle provides any facility that we can create temporary table in memory? Pls provides me idea about it.
    - Hiren Modi

    http://www.oracle-base.com/articles/8i/TemporaryTables.php
    http://www.dba-oracle.com/t_temporary_tables_sql.htm
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/tables.htm#i1006400
    You can search the oracle documentation for this as well.

  • Oracle's Temporary Table Use/Session Management

    I'm wondering about the session management that the JSQL services use. We have an app that uses a standard Oracle user but we manage the users via the application. We are using the temporary table feature in Oracle as it allows for session specific data to be created, read, etc for that single session.
    Is there a way for me to force each new web user into it's own session (that will span across multiple XSQL pages) so that we can continue to use this functionality.
    Thanks.

    Not using the built-in connection manager, but the latest versions of the XSQL Pages framework allow you to provide your own implementation of a connection manager that could be a custom implementation like this.

  • Performance issue with Oracle Global Temporary table

    Hi
    Oracle version : 10.2.0.3.0 - Production
    We have an application in Java / Oracle. Users request comes in XML and oracle parser parses it and inserts it into Global temporary tables and then Business Stored procedure picks data from these GTT's and do the required processing.
    in the end data required response data is again inserted into response GTT's from which Response XML is generated.
    Question : Is the use of Global temporary tables in Oracle degrades performance as we have large number of GTT's in our application approx. 5-600 such tables.
    Regards,
    Vikas Kumar

    Hi All,
    Here is architecture of my application:
    Java application creates XML from the screen values and then inserts that XML
    into a framework(separate DB schema) table . then Java calls a Stored Procedure from same framework DB and in SP we have following steps.
    1. It fatches XML from the XML type table and inserts XML into screen specific XML TYPE table in the framework DB Schema. This table has a trigger which parses XML and then inserts XML values into GTT which are created in separate product schemas.
    2. it calls Product SP and then in product SP we have business logic. Product SP
    does the execution and then inserts response into Response GTT.
    3. Response XML is created by using XML generation function and response GTT.
    I hope u will understand my architeture this time and now let me know if GTT are good in this scenario or not. also please not that i need data in GTT only during execution and not after that. i dont want to do specific delete which i have to do if i am using normal tables.
    Regards,
    Vikas Kumar

  • Oracle 10g - Insert in to Temporary Table - Record count mismatch between s

    We are trying insert records from a select query in to temporary table, some of the records is missing in the temporary table. The select statement is having multiple joins and union all which it little complex query. In simple terms the script contains 2 part 1st Part Insert in to temporary table 2nd part Select query with multiple joins, inline sub queries, unions and group by classes and conditions
    Eg. If we execute select statement alone it returns some count for example => 60000 After inserting into the temp table, in temp table the count is around 42000 why is the difference?
    It is simple bulk inserts... insert in to temp table select from xxx. also, there is no commit in between. The problem is all the records populated by the select statement are not inserted in to temp table. some records are not inserted.*
    Also, we had some other observation. It only happens in its 2nd execution and not its first run. Hope there might be some cache problem
    Even, we also did not believe that. We are wondering. In TOAD, we tested however at times it happens. In application jar file, after "insert in to temp select * from xxx" we take the i. record count of temp table and ii. record count of "select * from xxx" separately but both doesn't match. Match only at 1st time.
    Thank you in advance for your efforts and help.
    Shiva.

    The code looks like
    sql = "insert in to temptable select x,y,z,.... from xxx,abc,pqr..where...."; (logial but not real is very complex around 700 lines with multiple joins, inline sub queries, group by etc. )
    stmt = conn.createStatement();
    rCount= stmt.executeUpdate(sql);
    Actual issue is
    rCount = xxxx = Count(temptable) < count(select x,y,z,.... from xxx,abc,pqr..where....)
    why this diffference ? some records populated in the select but not inserted in to temp table
    Anyone can explain?

  • How create temporary table from list of values

    Can you anybody advise me how can I create temporary table from list of values? I have list of values and need create temporary table for next use with command JOIN etc.
    Thank you for help

    NO, you can not create temporary table in oracle on the fly ( Like #Tabels in SQl Server or Sybase ) , you will have to use the GTT i.e Global Temporary Tables
    check the following link GTT :
    to flush the tables after commit
    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.
    so to keep rows in Table after commit
    CREATE GLOBAL TEMPORARY TABLE my_temp_table (
      column1  NUMBER,
      column2  NUMBER
    ) ON COMMIT PRESERVE ROWS;

Maybe you are looking for

  • Application server file length to internal table

    i am having a flat file in the appliaction server and it is 350 characters length stored for each line. i mean like purchase order,matner,material text, kunnr,customer address etc, this all will be 365 chars including spaces. I have decalred the file

  • ALV GRID DISPLAY USING FACTORY METHODS

    Hi all I am using factory methods for my alv grid display. I have a list of functionalities, for which i am not able to find a correct method.. 1) Header of alv(with all the values of the selection-screen) 2)How to give text to a subtotal(ed) column,

  • Creating 2 table maintainance views for one custom table

    Hello All, I want to create 2 table maintainace views for one custom table. I know how to create table maintainace but I want to know whether we can create only one maintainance view or we cal also create 2 maintainace views for a single custom table

  • MDB+JMS+JMSAppender

    Hi, I'm trying to run JMSAppender i have a few questions. First is related with MDB. I deployed it on Oracle9iAS this kind of mdb: <message-driven > <description><![CDATA[]]></description> <display-name>iateLogginMDB</display-name> <ejb-name>iateLogg

  • Search for column in all tables

    I want to search for a column value(example instance_id=123456) in all the tables using one query rather than describing each table to find first if instance id exist and if so do a select from that table.