Best options to use in Temp Table

Hello,
I was just trying to figure out the best options we can choose with when we come across a scenario where we need to use a  Temp Table/Table Variable/Create
a Temp Table on the fly.
However, I could not see any big difference in using those options. As per my understanding using a table variable is more convenient if the query logic is
small and the result set also will be comparatively small.Creating a temp table is also an easy option but it takes much time and we can not create any indexes on it. I am working on a query optimization task where in plenty of temp tables are used
and the query takes more than five minutes to execute. We have created few indexes and all in few tables and reduced the query execution time up to 2 mnts.Can anyone give me more suggestions on it. I have gone through various articles about it and came to
know that there is no one solution for this and I am aware of the basic criteria like  use Set No count on, Order the table in which the indexes are created, Do not use Select * instead use only columns which are really required, Create Indexes
and all. Other than these I am stuck with the usage of temp tables. There are some limitations where I can convert all the Temp table logic to CTE (I am not saying its not possible, I really dont have time to spend for the conversion). Any suggestions are
welcome.
Actual Query
select Code,dbo.GetTranslatedText(Name,'en-US')
as Name from ProductionResponse.ProductionResponse
00.00.02
5225 rows
With Table Variable
DECLARE  @General
TABLE(Code
NVarchar(Max),Name
NVarchar(Max)
INSERT
INTO @General
select Code,dbo.GetTranslatedText(Name,'en-US')
AS Name  from ProductionResponse.ProductionResponse
select
* from @General
00.00.03
5225 rows
With an Identity Column
DECLARE  @General
TABLE(Id
INT IDENTITY(1,1)
,Code NVarchar(Max),Name
NVarchar(Max)
INSERT
INTO @General
select Code,dbo.GetTranslatedText(Name,'en-US')
AS Number  from ProductionResponse.ProductionResponse
select
* from @General
00.00.04
5225 rows
With Temp Table:
CREATE
TABLE #General (Id
INT IDENTITY(1,1)
PRIMARY KEY,Code
NVarchar(Max),Name
NVarchar(Max)
INSERT
INTO #General
select Code,dbo.GetTranslatedText(Name,'en-US')
as Name from ProductionResponse.ProductionResponse
select
* from #General
DROP
TABLE #General
00.00.04
5225 rows
With Temp Table on the Fly
SELECT G.Code,G.Name
INTO #General  
FROM
select Code,dbo.GetTranslatedText(Name,'en-US')
as Name from ProductionResponse.ProductionResponse
)G
select
* from #General
00.00.04
5225 rows

>> I was just trying to figure out the best options we can choose with when we come across a scenario where we need to use a Temp Table/Table Variable/Create a Temp Table on the fly. <<
Actually, we want to avoid all of those things in a declarative/functional language. The goal is to write the solution in a single statement. What you are doing is mimicking a scratch tape in a 1950's tape file system. 
Another non-declarative technique is to use UDFs, to mimic 1950's procedural code or OO style methods. Your sample code is full of COBOL-isms! In RDBMS we follow ISO-11179 rules, so we have “<something in particular>_code” rather than just “code” like
a field within a COBOL record. The hierarchical record structure provides context, but in RDBMS, data elements are global.  Or better, they are universal names. 
>> I am aware of the basic criteria like use SET NO COUNT ON, Order the table in which the indexes are created, Do not use SELECT * instead use only columns which are really required, CREATE INDEXes and all.<<
All good, but you missed others. Never use the same name for a data element (scalars) and a table (sets). Think about what things like “ProductionResponse.production_response” means. A set with one element is a bit weird, but that is what you said. Also, what
is this response? A code? A count? It lacks what we call an attribute property. 
This was one of the flaws we inherited when ANSI standardized SQL and we should have fixed it. Oh well, too late now. 
Never use NVARCHAR(MAX). Why do you need to put all of the Soto Zen sutras in Chinese Unicode? When you use over-sized data elements, you eventually get garbage data. 
>> Other than these I am stuck with the usage of temp tables. There are some limitations where I can convert all the Temp table logic to CTE (I am not saying its not possible, I really do not have time to spend for the conversion). Any suggestions are
welcome.<<
Yes! This is how we do declarative/functional programming! Make the effort, so the optimizer can work, so you can use parallelism and so you can port your code out of T-SQL dialect. 
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL

Similar Messages

  • Use global temp table for DML error logging

    our database is 11.2.0.4 enterprise edition on solaris 10
    we are wondering if anyone has an opinion of or has done this before, to use a global temp table for DML error logging. We have a fairly busy transactional database with 2 hot tables for inserts. The regular error table created with dbms_errlog has caused many deadlocks which we don't quite understand yet. we have thought using global temp table for the purpose, and that seemed to work, but we can't read error from the GTT, the table is empty even reading from the same session as inserts. Does anyone have an idea why?
    Thanks

    The insert into the error logging table is done with a recursive transaction therefore it's private from your session which is doing the actual insert.
    Adapted from http://oracle-base.com/articles/10g/dml-error-logging-10gr2.php
    INSERT INTO dest
    SELECT *
    FROM  source
    LOG ERRORS INTO err$_dest ('INSERT') REJECT LIMIT UNLIMITED;
    99,998 rows inserted.
    select count(*) from dest;
      COUNT(*)
        99998
    SELECT *
    FROM  err$_dest
    WHERE  ora_err_tag$ = 'INSERT';
    1400    "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")"        I    INSERT    1000        Description for 1000
    1400    "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")"        I    INSERT    10000        Description for 10000
    1400    "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")"        I    INSERT    1000        Description for 1000
    1400    "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")"        I    INSERT    10000        Description for 10000
    rollback;
    select count(*) from dest;
      COUNT(*)
            0
    SELECT *
    FROM  err$_dest
    WHERE  ora_err_tag$ = 'INSERT';
    1400    "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")"        I    INSERT    1000        Description for 1000
    1400    "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")"        I    INSERT    10000        Description for 10000
    1400    "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")"        I    INSERT    1000        Description for 1000
    1400    "ORA-01400: cannot insert NULL into ("E668983_DBA"."DEST"."CODE")"        I    INSERT    10000        Description for 10000

  • Best options for using my current cell phone while visiting England

    I am going to be visiting England for over 2 weeks.   what is the best option for me to be able to use my cell phone while I am there to call my family in the USA.   The International rate is way way toooooo expensive @ $ . 65 per minute.
    Thanks,
    Sharon

    sdsess wrote:
    I am going to be visiting England for over 2 weeks.   what is the best option for me to be able to use my cell phone while I am there to call my family in the USA.   The International rate is way way toooooo expensive @ $ . 65 per minute.
    Thanks,
    Sharon
    Is your phone the LG Cosmos, as it says by your profile?   This phone won't work as a phone in the UK (which is GSM, and the Cosmos is CDMA-only).  Don't think is has Wifi either, so Skype is out.
    So choices are to get a "loaner" phone from Verizon's Occasional Global traveller program, http://b2b.vzw.com/international/Global_Travel/index.html 
    or buy a cheap GSM phone in the UK.   There are some great deals, e.g. from CarphoneWarehouse, which are everywhere...
    http://www.carphonewarehouse.com/mobiles/choose-tariff/ALCATEL-OT-209/PPAY&clearance=false
    This phone costs 3GBP, around $5, you need a 10 pound top up.  And there are many others.  Just make sure it is unlocked, and then  it's easy to find SIMs which cost around 10c per min to the US.

  • How can I use Indexed Temp tables to optimize performance?

    Instead of joining two CTEs together, I am now going to attempt to join two indexed temp tables. 
    The first temp table is a number of encounters that returns 147 rows in 2 seconds. The second temp table
    is progress notes for all those encounters returning 136 rows in 18 seconds. Joining the indexed views comes back at 3 1/2 minutes.
    What can I do to optimize performance?
    Code is below. Thanks in advance!
    if object_id('tempdb..#arpb') is not null begin drop table #arpb end;
    if object_id('tempdb..#progress_notes') is not null begin drop table #progress_notes end;
    SELECT DISTINCT
    ARPB.PAT_ENC_CSN_ID, ARPB.SERVICE_DATE, ARPB.BILLING_PROV_ID, ARPB.DEPARTMENT_ID,
    SER.PROV_NAME, DEP.DEPARTMENT_NAME, E.APPT_TIME, ZC_APPT.NAME AS APPT_STATUS
    INTO #arpb
    FROM ARPB_TRANSACTIONS ARPB
    LEFT OUTER JOIN CLARITY_SER AS SER ON SER.PROV_ID = ARPB.BILLING_PROV_ID
    LEFT OUTER JOIN CLARITY_DEP AS DEP ON DEP.DEPARTMENT_ID = ARPB.DEPARTMENT_ID
    LEFT OUTER JOIN PAT_ENC AS E ON E.PAT_ENC_CSN_ID = ARPB.PAT_ENC_CSN_ID
    LEFT OUTER JOIN ZC_APPT_STATUS AS ZC_APPT ON ZC_APPT.APPT_STATUS_C = E.APPT_STATUS_C
    WHERE ARPB.DEPARTMENT_ID = xxxx
    AND ARPB.TX_TYPE_C = 1
    AND ARPB.VOID_DATE IS NULL
    AND ARPB.BILLING_PROV_ID = xxxx
    AND ARPB.SERVICE_DATE BETWEEN
    'xxxx' AND 'xxxxx'
    create clustered index idx_temp_arpb on #arpb(PAT_ENC_CSN_ID)
    SELECT DISTINCT
    ARPB.PAT_ENC_CSN_ID,
    ZCNT.NAME AS NOTE_TYPE, PR.NAME AS PURPOSE, HNO_INFO.NOTE_ID,
    EMP.NAME AS EMP_NAME, STS.NAME AS NOTE_STATUS
    INTO #progress_notes
    FROM ARPB_TRANSACTIONS ARPB
    LEFT OUTER JOIN ENC_NOTE_INFO AS ENC_NOTE_INFO ON ARPB.PAT_ENC_CSN_ID = ENC_NOTE_INFO.PAT_ENC_CSN_ID
    LEFT OUTER JOIN HNO_INFO AS HNO_INFO ON ENC_NOTE_INFO.ENCOUNTER_NOTE_ID = HNO_INFO.NOTE_ID
    LEFT OUTER JOIN ZC_NOTE_TYPE AS ZCNT ON ZCNT.NOTE_TYPE_C = ENC_NOTE_INFO.NOTE_TYPE_C
    LEFT OUTER JOIN ZC_NOTE_PURPOSE AS PR ON PR.NOTE_PURPOSE_C = HNO_INFO.NOTE_PURPOSE_C
    LEFT OUTER JOIN CLARITY_EMP AS EMP ON EMP.EPIC_EMP_ID = HNO_INFO.CURRENT_AUTHOR_ID
    LEFT OUTER JOIN ZC_NOTE_STATUS AS STS ON STS.NOTE_STATUS_C = ENC_NOTE_INFO.NOTE_STATUS_C
    WHERE ARPB.DEPARTMENT_ID = xxxx
    AND ARPB.TX_TYPE_C = 1
    AND ARPB.VOID_DATE IS NULL
    AND ARPB.BILLING_PROV_ID = xxxx
    AND ZCNT.NAME = 'xxxx'
    AND ARPB.SERVICE_DATE BETWEEN
    'xxxx' AND 'xxxx'
    AND PR.NAME = 'xxxxx'
    create index idx_temp_pn on #progress_notes(PAT_ENC_CSN_ID)
    SELECT
    #arpb.PAT_ENC_CSN_ID,
    #arpb.APPT_TIME,
    #arpb.SERVICE_DATE,
    #arpb.BILLING_PROV_ID,
    #arpb.PROV_NAME,
    #arpb.DEPARTMENT_ID,
    #arpb.DEPARTMENT_NAME,
    #progress_notes.EMP_NAME as NoteEmp,
    CASE #progress_notes.NOTE_ID
    WHEN null THEN 'No Progress Note'
    ELSE #progress_notes.NOTE_ID
    END as NoteId,
    #progress_notes.NOTE_STATUS,
    #progress_notes.NOTE_TYPE,
    #progress_notes.PURPOSE
    FROM #ARPB
    LEFT JOIN #PROGRESS_NOTES ON #ARPB.PAT_ENC_CSN_ID = #PROGRESS_NOTES.PAT_ENC_CSN_ID
    To err is human, to REALLY foul things up requires a computer

    Something is not right here. What is the type of that column in both temp tables?
    I would assume that joining 147 and 136 rows should be done in less than 1 sec. even without indexes.
    How did you measure the time?
    BTW, I suggest to use aliases in your last query - it will be easier to read. Also use COALESCE function instead of CASE for the Note_ID (BTW, is Note_ID a character column - otherwise you supposed to get an error).
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Best option to use iMac 27" as primary screen

    Can anyone please share the best option/accessory to use with the iMac 27" to make it the primary screen for watching HD TV and connecting PS3. I want to hook up these devices via HDMI to Mini Display Port link and was wondering if there is any lag or any other problem.
    I have researched on the net and found Belkin AV360 and Kanex. Any preferences?
    Thanks for your help in advance. Cheers

    Sorry, no the MM is simply too old. Please read Apple's FAQ on Target Display Mode and you will see:
    Target Display Mode: Frequently Asked Questions (FAQ)

  • Best option for using iPhoto on holiday

    I Practise a lot of photography and have a OCD about all my pictures being organised in iPhoto, with keywords, geotags, face recognition etc. I currently do this on my iMac to which my  iPhoto library is stored on a Seagate external 2tb hard drive via FireWire. The problem I find it's a lot of work when I get back and I'm stuck in the office for days organising, the solution I'm looking for is some how doing this on the go.
    THe first thing I thought is to get a Macbook pro or a MacBook Air, and just take my hard drive with with me, but I'm not sure if it will need to do a library rebuild every time I unplug from iMac to another device or is it just plug and  play, or could there be an option to do some thing with a mini mac or mini mac server as these appear a cheaper option to buy. Must places I go have a HD TV so could connect the mini mac to a TV or I imagine there's and option these days of using your mini mac on a iPad screen.
    Thanks in Advance, any advice appreciated
    Dan

    >> I'm not sure what the term "remote image" means exactly... I find the perfect image ... paste that photo into my post, would that be using a "remote image?"
    Yes
    3GB will go some way, so I'd upload your own, which avoids missing images when some other site changes. Layout/appearance should be the same for remote or uploaded.

  • Use Global Temp Table to overcome Mutating Trigger issue

    Hello all. I need to delete a line in a table, and thought I would get around the mutating trigger issue by creating a GTB table. I created 2 different triggers. One is a Row level trigger, the other a Statement level trigger.
    The first trigger gathers the information I need to identify the line I want to delete. This is:
    CREATE OR REPLACE TRIGGER Requisition_Capture
    AFTER UPDATE OF Delivery_Code on Supply_Items
    FOR EACH ROW
    BEGIN
      IF :NEW.Delivery_Code = '#' THEN
        INSERT INTO Requisition_Storage
          (Req_Code)
        VALUES
          (:NEW.Requisition_Code);
      END IF;
    END;And the second trigger deletes the line:
    CREATE OR REPLACE TRIGGER SUPPLY_ITEM_RESET
    AFTER INSERT ON Requisition_Storage
    DECLARE
    BEGIN
      DELETE FROM Supply_Items r
       WHERE r.Requisition_Code =
             (SELECT t.Req_Code
                FROM Requisition_Storage t, Supply_Items s
               WHERE t.Req_Code = s.Requisition_Code)
         AND r.Order_Qty = 0;
    END;The GTB is as follows stores the information I need to delete the line.:
    -- Create table
    create global temporary table REQUISITION_STORAGE
      req_code VARCHAR2(20)
    on commit delete rows;When the column Delivery_Code is updated in the Supply_Item table, and the value is reset to '#', I want to capture the Requisition_Code in the GTB, so I can run the statement level trigger and delete the reset row. However, I still have a mutating error problem. What am I missing?

    The statement level trigger would need to be an AFTER UPDATE OF Supply_Items for this to work around the mutating trigger issue. You need to ensure that your UPDATE has finished updating all the rows that it is going to update before your statement-level trigger runs.
    As has been pointed out, however, the desire to work around a mutating trigger error almost always indicates that you have a data model problem. And you're almost always better served by fixing the data model than working around the error.
    Justin

  • Which option to use to search text in multiple table columns

    Hi, I have a case where I have 4 db tables. On the UI there is an option to search a keyword from some columns of these 4 tables.
    Table1 = summary, description are the columns user can search on
    Table2 = project_name is the column user can search on
    Table3 = need_by_date is the column user can search on
    Table4 = owner is the column user can search on
    On the UI, user can enter a keyword and check the columns they want to search on. Out of the above, they can check one column, or more, or all.
    My question is what is the best option to use oracle text search in this case.
    Option 1 = I create a procedure to select these columns and then create an index on this procedure. In this case, is there a way to specify
    which columns to search on?
    Option 2= Create 4 separate indexes on these table/columns and then query the columns which user has selected to search on.
    Any other better idea?

    Hi,
    multicolumn only works on columns in the same table.
    If you can also query just on one field, then an index per field will be preferable. If you query always on all the fields then the one index approach is good. For this last the options are:
    1. Use User_datastore, create a procedure and a dummy column
    2. Create a materialized view for the query and build an index on this materialized view
    3. Store the fields as an xml in the main table and index the xml column.
    The maintanance of options 1 and 3 are bigger, because you need triggers to be aware of an update. Option 2 and 3 will need more storage.
    Herald ten Dam
    http://htendam.wordpress.com

  • Issue in Temp table creation in PCM Databridge and data migration from ecc to PCM using databridge

    Hi,
    we are working on mapping SAP PCM table structure data and the data which is coming from ECC.
    We are using Databridge tool to upload the data for the same,upload from databridge involves
    using Specification file to upload the data into SAP PCM.
    The problem we are facing is that
    The responsiblity center(cost center) in ECC and SAP PCm are different.There is one to many relationship between them
    eg 1 ecc cost center-->many SAP PCM cst center,we need to split the line item vale of one ecc cost center into many SAP PCM cost centers
    eg C1 cost center from ECC has value 4000 to be split across PCM1,PCM2,PCM3,PCM4 cost centers in SAP PCM
    we need to automate using the databridge ,we are stuck up in this task.
    Please guide us.
    Also we are trying to create temporary table usinf Table temporary command in SPE file of databridge.The purpose of this is to put the ECC data in temp table as per our req and then use the temp table as data source for putting data in PCm as per our requirement.
    Please advise us on this approach
    Regards
    Shrirang
    9552334897

    Schema's SYS,CTXSYS, MDSYS and ORDSYS are Not Exported using exp/expdp
    Doc ID: Note:228482.1
    I suppose he already installed a software 12c and created a database itseems - So when you imported you might have this "already exists"
    Whenever the database is created and software installed by default system,sys,sysaux will be created.

  • Please help - Can not use stored procedure with CTE and temp table in OLEDB source

    Hi,
       I am going to create a simple package. It has OLEDB source , a Derived transformation and a OLEDB Target database.
    Now, for the OLEDB Source, I have a stored procedure with CTE and there are many temp tables inside it. When I give like EXEC <Procedure name> then I am getting the error like ''The metadata  could not be determined because statement with CTE.......uses
    temp table. 
    Please help me how to resolve this ?

    you write to the temp tables that get created at the time the procedure runs I guess
    Instead do it a staged approach, run Execute SQL to populate them, then pull the data using the source.
    You must set retainsameconnection to TRUE to be able to use the temp tables
    Arthur My Blog

  • How to use temp table/variable

    Hello,
    It's SQL 2008 R2. I need to bring data from Oracle using .Net Providers/ODBC Data Provider to MS SQL table converting Oracle UTC dates to PST.  The source connection type cannot be changed as it's given. For the Destination I'm using the OLE DB.
    As the truncate all and load could take time I'm trying to use a temp table or a variable to use it further with t-sql merge or not exists to bring/add the only new records to the destination table.
    I'm trying different scenarios that is all failed.
    Scenario A:
    1. In DTF after OLE DB Source I'm using the Derived Colum to convert dates. It's working well.
    2. Then use Recordset Destination with an object variable User::obj_TableACD. It's also working well.
    3. Then I created a string variable with a simple query that I could modify later "select * from " + (DT_WSTR,10)@[User::obj_TableACD] trying to get data from the recordset object variable but it's not working.
    Scenario B:
    1. Created a store procedure to create a temp table.
    2. Created a string variable to execute SP str_CreateTempTable: "EXEC dbo.TempTable". It's working well with the SQL Task with SQLSourceType as Variable.
    3. Then how to populate the temp table from the Oracle source to bring data into the Destination?
    I could spend another few days to figure it out. So, please help me on it if there is a way to solve it.
    Thanks

    Thank you so much, Nitesh. Now, I got the understanding of temp tables in SSIS. However, in my case to implement t-sql merge or not exists to bring the new records only I'd need to load at least a one table into a temp table anyway. So, why not to use a
    destination table instead. I also noticed a one remark from the article you suggested that the expert who wrote the article had never actual used the temp tables in SSIS.
    So, I decided to go with truncate, drop keys, derive columns, load, and create keys again in the destination table.
    Thank you again, I'll reserve the knowledge I got for the temp SSIS tables for some other cases.

  • Collection x temp table - what is the best title?

    In which of the structures bellow the performance is better? In the first, I use a collection with forall. In the second, I use a temp table with for loop.
    Consider the data to be the same in both the collection and the temp table.
    case 1 - collection:
    DECLARE
    TYPE NumList IS VARRAY(10000) OF NUMBER;
    depts NumList := NumList(10, 30, 70 ... 10000); -- department numbers
    BEGIN
    FORALL i IN depts.FIRST..depts.LAST
    DELETE FROM emp WHERE deptno = depts(i);
    END;
    case 2 - temp table:
    -- temp table
    create global temporary table depts
    num number
    -- inserts
    insert into depts (num) values (10);
    insert into depts (num) values (30);
    insert into depts (num) values (10000);
    -- code
    BEGIN
    FOR i IN (select num from depts) LOOP
    DELETE FROM emp WHERE deptno = i.num;
    END LOOP;
    END;

    Do you need loop in Case 2?
    Wouldn't this do?
    DELETE FROM emp WHERE deptno IN (select num from depts);Check this Collections vs table for discussion on similar topic

  • Visual Basic, DAO, Temp tables in stored procedures

    Client code currently uses DAO with SQLPassthrough option in VB to connect to SQl 6.5 db.
    I migrated all stored procedures with default options except Oracle 8i temp tables. For every procedure a package and a procedure was created. We use SQL server temporary tables extensively in a few hundred stored procedures. The ref cursor created refers to the temporary table. While migratiing, Create table statement is commented. How are SQL6.5 equivalent of temp tables handled in Oracle? Is there an alternative to temp tables?
    I also migrated to another oracle db using the INOUT type for stored procedures. This time only procedures were created. Can these procedures return a record set in DAO with SQLPAssthrough?
    How do you call a procedure using DAO in VB to get recordsets?
    What is the best way to migrate to Oracle with minimal client code changes?
    Thank you in advance.
    Umesh
    null

    Karthick_Arp wrote:
    BluShadow wrote:
    I agree with Karthick, there's no need for a temporary table in this situation.
    And to add, temporary tables should not be created at runtime, they should be part of the initial design of the database, created once and used as needed. Creating them at runtime is just wrong.The problem is the name oracle has given to GTT. The word Temporary mislead lot of SQL Server developers and they think its something same as the temporary table used in SQL Server :)Yeah, Ingres does something similar to SQL Server too, in that you can create a temporary table (Ingres assigned it a unique name and tells you what it is), and you set an expiry time on it (i.e. set it to expire in 1 days time), and then a background process is supposed to clean up the tables that have expired. Unlike Oracle, they are not session specific, but become visible to all once created.
    I think there's room for both types of temporary table, but Oracle's does the job (except when you want to use them from a stateless application front end).

  • TEMP Tables: I hv yet to receive replies for prev mails

    Can we create temp tables from a PL/SQL block in 8i.
    If not how do we create it, using Dynamic PL/SQL. Any help will
    be appreciated.
    Thanks
    Anish
    null

    ANISH (guest) wrote:
    : Can we create temp tables from a PL/SQL block in 8i.
    : If not how do we create it, using Dynamic PL/SQL. Any help
    will
    : be appreciated.
    : Thanks
    : Anish
    Anish,
    Dynamic SQL will work. Though you have not mention how the temp
    table is going to be used, another option could be PL/SQL table;
    which is an array in PASCAL, C, Ada and other languages.
    If you are going to use the temp table to hold intermediary
    results, I will recommend considering PL/SQL table. Otherwise,
    dynamic SQL will the only option.
    If you are opting for dynamic SQL, you may want to pass in
    parameters such as tablespace name, table name, storage
    parameters, etc. Then, this procedure can be used to create more
    than one table.
    Regards,
    John
    null

  • Global Temp tables in standy-by db

    Hi All,
    Can i use Global temp tables in a stand by database?
    The temp tables will be used for dml purpose.
    oracle version is 10g R2
    RHEL 5
    Thanks,
    Ajay Kumar

    Physical standby :
    No DMLs are allowed on the standby database and the most important things is that Standby databases can always be opened in READ-ONLY mode which won't allow DMLs.
    Logical standby :
    Logical standby database may have different structure from primary database. When it is in read-only mode SQL statements generated from redo are applied and queries may be run concurrently. When in read-write mode one can modify data in tables created in addition to primary schema. But this setting may be over written by specifying additional security options.
    http://oracleonline.info/standby_database_type.html
    http://download.oracle.com/docs/cd/B10500_01/server.920/a96653/manage_ls.htm
    Thanks

Maybe you are looking for