Flashback and truncate table in 11gR2

Hi,
From what I can gather, flashback database is the only flashback operation that can undo a table truncate. A truncate table operation cannot be rolled back, because it does not produce the undo data necessary for undo based flashback operations like Flashback query, version, transaction/backup and table.
Is this assessment correct?
Thanks.

Pal wrote:
Thanks for reply. I hope it's ok to add a couple more related questions:
SQL> select current_scn from v$database;
1088080
SQL> connect hr/hr
SQL> truncate table test_data;
SQL> select * from test_data as of SCN 1088080;
ORA-01466: unable to read data - table definition has changedYes, that's correct Pal. The reason is that with any DDL , the structure/definition of the table would be changed and Flashback Query won't be allowed on such table.
I cannot use Flashback Query, however, just reading http://ocpdba.wordpress.com/2009/10/19/reversing-the-effect-of-a-truncate-table-in-oracle-11gr2 which demonstrates how to use Flashback Data Archive and Flashback Query to reverse a table truncate operation.
Why does Flashback Data Archive allow me to use Flashback Query past DDL operations?Please see,
http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17125/adfns_flashback.htm#BJFJHDAG
Actually, even with the Flasback data archive too, you can't do anything if the table structure is modified by a command whose effect it can't tolerate. In 11.2, what is given is that you can dissociate your table from the Flashback DAta archive using the package DBMS_FLASHBACK_ARCHIVE.DISASSOCIATE_FBA , do the changes on both target and archive table and then reassociate . Oracle does makes a note in this operation that assume no aboslute guarantee in the data's accuracy if you would do this procedure.
If I do not have Flashback Data Archive enabled on a table, how can I determine the SCN to undo a truncate table using Flashback database or TSPITR?You would need to mine the logfile using the logminer .
HTH
Aman....

Similar Messages

  • Flashback the truncate table is possible in 11g?

    Is it possible, to recover the truncate table data using flashback? with out any db downtime. if yes, steps please.

    Phil Florent wrote:
    Flashback is a great thing but the olds methods are still there. You can do a restoration/recover of a part of your database (the minimum required + the datafile(s) with the segment(s) you need) and then open this small database, export the table and import it in your original database. No downtime.For sure, that's good to point out.
    The OP was asking specifically about FlashBack so i assumed (perhaps incorrectly) those methods were ruled out already for whatever reasons. Never hurts to have too much information though, unless your brain happens to explode i suppose :)

  • Ssis package error need help to fix it. though disabled all triggers and droped all the foreign keys and truncated tables on pipeline constraints.

    [PartyName1 [6672]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
    An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80004005  Description: "Transaction (Process ID 1414) was deadlocked on lock resources with another process and has been chosen as the
    deadlock victim. Rerun the transaction.".

    you need to provide Details about your package like what is source/destination.. any SQL query/where is the exact deadlock point.
    Please check the following links which may help you.
    http://blogs.technet.com/b/fort_sql/archive/2011/12/12/get-rid-of-deadlocks.aspx
    http://msdn.microsoft.com/en-us/library/ms191242.aspx
    Let us TRY this |
    My Blog :: http://quest4gen.blogspot.com/

  • Truncate table and materialized view log

    I user oracle 10 R2
    I have a table and on that table a materialized view log.
    I execute in a pl/sql procedure:
    1) execute immediate('drop materialized view log on tab1');
    then:
    2) execute immediate('truncate table tab1');
    3) Now I insert a lot of records in tab1
    4) execute immediate('create materialized view log on tab1 WITH rowid INCLUDING NEW VALUES');
    When I create the materialized view log I recieved this message:
    ora32321: refresh fast on tab2 unsupported after detail table truncate
    Why?

    Refresh fast after truncate operation on container table is not supported, regardless the container table is or is not partitioned.
    Perform a refresh complete.
    ORA-32321 :
    Cause:     A detail table has been truncated and no materialized view
         supports fast refersh after a detail table has been truncated
    Action:     Use REFRESH COMPLETE. Note: you can determine why your
         materialized view does not support fast refresh after TRUNCATE
         using the DBMS_MVIEW.EXPLAIN_MV() API.

  • Problem in enabling constraint - after disabling and truncation of table .

    Hello Friends,
    I have a table called DRR_TABLES that has list of table names . The requirement is to truncate the tables present in DRR_TABLES except KEY_IDS table and table_name like '%TYPE%' table.
    written a procedure . successfullly truncating the tables from DRR_TABLES but while enabling constraints after truncation , I am getting problem in enabling constraints .
    ERROR at line 1:
    ORA-02270: no matching unique or primary key for this column-list
    ORA-06512: at "schema123.TRUNCATE_DRR_TABLES ", line 49
    ORA-06512: at line 1
    Heres is the code .
    PROCEDURE TRUNCATE_DRR_TABLES is
    x varchar2(200);
    v_tablecount number := 0;
    cursor c is select TABLE_NAME from DRR_TABLES where population_source='PUBLISHING' and TABLE_NAME != 'KEY_IDS' and TABLE_NAME NOT LIKE '%TYPE%';
    BEGIN
    DBMS_OUTPUT.PUT_LINE (' TRUNCATING DRR TABLES ...........');
    OPEN c ;
    LOOP
    FETCH c INTO x ;
    EXIT WHEN c%NOTFOUND;
    for c1 in (select table_name, constraint_name from user_constraints where TABLE_NAME = x and status ='ENABLED' ORDER BY CONSTRAINT_TYPE DESC )
    loop
    begin
    execute immediate ('alter table '||c1.table_name||' disable constraint '||c1.constraint_name|| ' cascade');
    NULL;
    end;
    end loop;
    EXECUTE IMMEDIATE 'TRUNCATE TABLE ' || x ;
    v_tablecount := v_tablecount + 1 ;
    DBMS_OUTPUT.PUT_LINE('TABLE TRUNCATED :'|| x );
    END LOOP ;
    DBMS_OUTPUT.PUT_LINE (' TOTAL TABLES TRUNCATED ' || v_tablecount );
    CLOSE c;
    OPEN c ;
    LOOP
    FETCH c INTO x ;
    EXIT WHEN c%NOTFOUND;
    for c2 in (select table_name, constraint_name from user_constraints where TABLE_NAME = x and status = 'DISABLED' ORDER BY CONSTRAINT_TYPE)
    loop
    begin
    execute immediate ('alter table '||c2.table_name||' enable constraint '||c2.constraint_name);
    NULL;
    end;
    end loop;
    END LOOP ;
    CLOSE c ;
    END TRUNCATE_DRR_TABLES ;
    LINE 49 is the line corresponding to enable constraint statement.
    Edited by: kumar73 on 3 Sep, 2012 11:44 PM

    It is such a pity that a user having 321 posts till date is unaware of basics of Posting a Question.
    1. You need to provide us with your Oracle version
    select * from v$version;2. You need to understand and get accustomed to using tags before and after Code or SQL's for better readability.
    3. You need to provide us with the Table Structure and the Constraints Definition.
    There are many things that looks like Bad Coding practices:
    <font face="Times New Roman" size=2>
    1. Avoid RBAR (Loops).
    2. Implement Bulk Collect.
    3. Why do you need to disable the constraints before truncating? Are you kind of handling the Referential Integrity Constraints?
    4. Duplicate checking of Disabled Constraints.
    5. When the procedure is being executed at Production Environment, are you going to Monitor the DBMS_OUTPUT? Why not Log the Statements into a LOG Table?
    6. Why use a TableCount variable? Would the TableCount Variable be not equal to the Number of Records returned by Cursor C?
    7. What is the need to use a NULL statement after every Execute Immediate?
    8. What is the Need to surround each execute Immediate with Begin .. End block?
    9. Where is your Exception handling Block? Forgot to write?
    </font>
    What has been your effort in finding which Constraint/Table is causing you the trouble?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Shrink table and Truncate/delete command

    Friends ,
    Regarding truncate cmmand we know ,
    "Truncate table removes all rows from a table, but the table structure and its columns, constraints, indexes etc., remains as it is."
    That means the table's data are deleted but the block is still not free .Blocks are still use the information of table's structue & others . In this case , if I shrink that table then what happen ? Are these blocks are going to be free or still contain the structure and its columns, constraints, indexes informaton ? Blocks becomes unused or used ?
    Waiting for reply ... ...

    Shippon,
    Trucate table <table> with 2 options
    1. reuse storage : leaces the space currently used by deleted rows: Leaves the HWM to where it is
    2. drop stroage: deallocated the space currently used by deleted rows: Resets the HWM to zero
    Are these blocks are going to be free or still contain the structure and its columns, constraints, indexes informaton ? Blocks becomes unused or used ?
    The  cleaned up blocks contains data and not the structure and indexes information. Truncate is just dropping data not structure (metadata). Blocks will be reused by my_objects again if "REUSE" option used, and if "DROP" option used, then blocks will be available to all the objects on residing on that tablespace.
    _*Example*_
    TABLE_NAME                       NUM_ROWS     BLOCKS INITIAL_EXTENT EMPTY_BLOCKS
    MY_OBJECTS                          84018        625          81920           15
    1 row selected.
    Truncate table my_object reuse storage;
    TABLE_NAME                       NUM_ROWS     BLOCKS INITIAL_EXTENT   EMPTY_BLOCKS
    MY_OBJECTS                              0                 0          81920                         640
    1 row selected.
    Truncate table my_object drop storage;
    TABLE_NAME                       NUM_ROWS     BLOCKS INITIAL_EXTENT     EMPTY_BLOCKS
    MY_OBJECTS                              0                 0          81920                             8
    1 row selected.Regards

  • Easy to truncate tables and load to server again?

    I have 125 tables to work on. I  developed proc to  disable and enable constraints and triggers. What I want to do is create a SSIS package which pull all the tables and disable triggers/constraint before load and  enable triggers/constraint
    after load and truncate all the previous tables. I am trying to find which way is easy and quicker way to do this requirements?

    Just run this proc from the package as Execute SQL Task. One would be to disable, another to enable.
    Arthur My Blog

  • Truncate Tables

    Is it possible to truncate tables or table partitions in a physical standby database using dataguard.
    The reason behind this is we do not need to carry forward data into the standby more than a certain period. The table is more of a datawarehouse table.
    Is this possible on dataguard 11g R1.
    Thanks,

    Hi,
    aprarently this is not possible. A physical data guard configuration is marked by the fact that primary and standby database are bitwise identical (spreaking from the data files here).
    So it is not possible - even in 11g. In 11g you can open the standby database, modify data and flashback the database to the point you started modifying the standby and continue apply
    the redo log data.
    If you want a solution: You can use streams to replicate the data to another database. In this "another" database you are free to truncate the data. Or you can use
    a logical standby database where you can truncate the table as well.
    Ronny Egner
    My blog: http://ronnyegner.wordpress.com

  • Full Load: Error while executing :TRUNCATE TABLE: S_ETL_PARAM

    Hi All,
    We are using Bi Apps 7.9.6.1. Full Load was running fine. But Now we are facing a problem with truncating a table "S_ETL_PARAM".
    I have restart informatica Server And also DAC Srever. But still I am getting the same in the DAC Log as, *"NOMALY INFO::: Error while executing : TRUNCATE TABLE:S_ETL_PARAM*
    *MESSAGE:::com.siebel.etl.database.IllegalSQLQueryException: DBConnection_OLTP:SIEBTRUN ('siebel.S_ETL_PARAM')*
    *Values :*
    *Null Map*
    *EXCEPTION CLASS::: java.lang.Exception"*
    Any Suggestion.....
    Thanks in Advance,
    Deepak

    are you trying to run incremental load when you get this truncate error? can you re-run full load and see that still runs ok? pls also check your DW side database logs like alert lor any DB level issue. such errors do not throw friendly messages in DAC/Informatica side.

  • Drop and recreate table in stored procedure

    Hi all
    When creating tables using Transact-SQL scripts, I have always preferred to drop the table if it exists and then create it explicitly using CREATE TABLE.  For two reasons:
    1) It does not matter if it is the first time the SP is run ie. if I create the table manually in the first instance and just use TRUNCATE TABLE it could fail if the table is deleted
    2) I have control over the data types of the table fields
    Just recently though I discovered the error that can occur when dropping and creating a table in the same batch (see link below)
    Microsoft Website
    This causes me a problem when dropping and creating tables in stored procedures, as I understand that a stored procedure is in itself a single batch?
    Can I avoid this error in a stored procedure whilst continuing to drop and create tables?  Or should I be taking a different approach?
    Coding best practice advice would be greatly appreciated.
    Thank you

    Thanks Ronen
    Please see my second post immediately before your reply.
    Given that I need to store the data output in a physical table for use in QlikView, would you suggest truncating the table each time the SP runs?  And then having a script that handles both dropping and creating the physical table, and also creating
    the SP?
    >> QlikView
    QlikView is an Israeli company, right?
    In any case I am not familiar with QlikView's application, therefore I can only give you general information, based on assumptions regarding the application, and facts regarding the SQL Server.
    >> for use in QlikView
    I assume that external application use specific database structure (table
    structure) and it is change only in rare situations (for example CMS interface might change the tables if and when a module s update/install). In this case there is no need to drop the table and recreate it and TRUNCATE is the solution.
    >> would you suggest truncating the table each time the SP runs
    I am sorry but i cant recommend on TRUNCATE a table each time you execute SP, without know the exact reason for this logic. It sound to me, at this point of time (with the information that we have), that this
    is very bad logic (application architecture). As I wrote above, basing your application on TRUNCATING the table each time mean that you have problems with multi users. Thins about 2 people that try to execute the same SP at almost the same time. Think about
    locking in the SQL Server and bad data (one truncate while the other already inserted the new data and get no rows, if there is no locking).
    But TRUNCATE is much better in this case probably then DROP and DELETE, since it is faster, and locking will be shorter (hopefully the application use the correct locking). There are other reasons why TRUNCATE is better, and other people already mentioned
    most of them, but time in this scenario might be critical.
    >> having a script that handles both dropping and creating the physical table, and also creating the SP?
    I do not undestand what is this second step. we said that you truncate the table, so why do you need to
    dropping and creating the physical table and who
    creating the SP?
    Are you meaning that the application create the tables and SP?
    There are lot of application that during installation create the database structure. is this what you mean?
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • Release of space after delete/truncate table

    Hello,
    How does release of space after delete/truncate table works? Is the space used before deletion released once delete is complete or not? Will I see the space occupied by deleted table as free in dba_segments or will I need to reorganize the table (drop and recreate again?). Reason why I am asking is that I can see table with 0 rows, but in dba_segment I can see it is occupying few gigabytes....
    Thank you

    Here is a little illustration for you;
    SQL> conn ogan/password
    Connected.
    SQL> create table ogan_deneme as select * from all_objects;
    Table created.
    SQL> select count(*) from ogan_deneme;
      COUNT(*)
        228470
    SQL> set line 1000
    SQL> set pagesize 1000
    SQL> select * from dba_segments where owner='OGAN';
    OWNER    SEGMENT_NAME        PARTITION_NAME           SEGMENT_TYPE       TABLESPACE_NAME                HEADER_FILE HEADER_BLOCK      BYTES     BLOCKS    EXTENTS INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS PCT_INCREASE  FREELISTS FREELIST_GROUPS RELATIVE_FNO BUFFER_
    OGAN      OGAN_DENEME          TABLE              SYSTEM                                 854       319981   *30408704*       *1856*         *44*          65536                       1  2147483645                       1               1          854 DEFAULT
    SQL> truncate table ogan_deneme;
    Table truncated.
    SQL> select * from dba_segments where owner='OGAN';
    OWNER    SEGMENT_NAME        PARTITION_NAME           SEGMENT_TYPE       TABLESPACE_NAME                HEADER_FILE HEADER_BLOCK      BYTES     BLOCKS    EXTENTS INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS PCT_INCREASE  FREELISTS FREELIST_GROUPS RELATIVE_FNO BUFFER_
    OGAN      OGAN_DENEME           TABLE              SYSTEM                                 854       319981      *65536*          *4*          *1*          65536                       1  2147483645                       1               1          854 DEFAULT
    SQL>Hope it Helps,
    Ogan

  • What is the recommended way to truncate tables in ODI?

    I want to create a separate step to truncate the result tables, before the start of the actual job. What is the recommended way of doing this?
    I am currently putting the truncate statements in the ODI procedure, but that has a lot of typing. Is there a odi command in the toolbox that I can use?
    Thanks.

    Ok,
    If the table will be loaded by interfaces, you have the "Truncate" option at the IKM's, just change it to "Yes".
    If you need to Truncate but they won't be loaded by Interfaces a possible way is:
    - requirements: it will be necessary to have some common "string" at tables names.
    1) create a procedure
    2) create an step
    3) at source tab put:
    Select table_name from user_tables where table_name in '%THE_STRING%'
    4) at target tab put:
    Truncate table #table_name
    If you don't have a common "string" you, instead, can create a table with all table names that you need to truncate and change the select command at 3).
    Does it help you?
    Message was edited by:
    Cezar_Santos

  • Truncate Table before Insert--Performance

    HI All,
    This post is in focus of special requirement where a table is truncated before inserting records in the table.
    Now, when a table is truncated the High Water Mark(HWK) is reset to lowest memory allocated for table in tablespace. After this, would insert with append can boost the performance of the insert query?
    In simple insert query, the oracle engine consults the free list to look for free spaces.
    But in insert with apppend, the engine starts above the HWM. And the argument is when truncate has been executes on table, would the freelist be used in simple insert.
    I just need to know if there are any benefits of using append insert on truncated table or simple insert would be same in term of performance with respect to insert with append.
    Regards
    Nits

    Hi,
    if you don't need the data truncate the table. There is no negativ impact whether you are using an conventional path or a direct path insert.
    If you use append less redo is written for the table if the table is in NOLOGGING mode, but redo is written for all indexes. I would recommand to create a full backup after that (if needed), because your table will not be recoverable after that (no REDO Information).
    Dim

  • Insert data Flatfile table to Parent and child tables

    Hi All,
        I have Flatfile table which is we getting from daily txt files and i want to populate flatfile data to parent as well as child tables. parent table has primary key as ID. This ID is foreign key of child tables. 
    Here i have mentioned our process.
    1. Flatfile duplicates has to remove with condition of daily date.
    2. Before Insert parent table have to check duplicate(we have Unique key of 4 columns in parent) if duplicate is there we have to delete duplicate then Insert into parent table unique records(Primary key is ID).(here why we are delete duplicate record meaning
    we getting daily files so if any records updated in future that record should be insert to parent and child table so only we delete old records and insert new records).
    3.After insert parent we have to populate child tables from Flatfile table as well as we have to insert parent table primary key as foreign key of child tables.
    4. if any truncation error occurs that errors should go to error log table.
    Right now we are using cursor for this concept and cursor has performance issue. so we are trying to optimize other way to populate parent and child table to increase performance to populate.
    Please help us to which way to do this process increase of performance .
    Please  can any one reply.

    Hi RajVasu,
    Since this issue is related to Transact-SQL, I will move this thread to Transact-SQL forum. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated. 
    Thank you for your understanding and support.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Use of truncating table

    Hi,
    I'm using some temporary load tables which are populated with bulk data daily & data is deleted after processing.
    During processing, I found that suddenly select statements became very slow inspite of very small data.
    Then I ran truncate command on the table & the select queries became faster as were before.
    Here I want to know the significance of running truncate on tables on a fixed time as there are tables in production which are being populated & deleted daily but never truncated.
    As truncate directly pulls down the water mark to 0, is there any option to do so using delete+commit?
    Thanks
    Deepak

    If you have temporary tables, you would generally want to declare them as GLOBAL TEMPORARY tables rather than declaring them as permanent tables. Life is generally much easier that way.
    If you do require permanent tables with transient data, you would need to use DDL to reset the high water mark, and TRUNCATE is the easiest option on that front. You may, however, be able to simply gather/ set statistics on the object that reflect the actual data volume to avoid any performance problems. Resetting the high water mark will only affect the performance of full table scans, but the CBO may choose full table scans less frequently if it has appropriate statistics on the table.
    Justin

Maybe you are looking for

  • Creating Planning Layout for GP12N  - Posting Period as columns/rows

    I am trying to create new layouts for GP12N, but do not know how to create the integrated layout with one column or one row for each Posting Period 1 - 12.  I did read that 'Sets' were not allowed.  Can anyone provide the steps necessary to allow Pos

  • WLan fails to connect after sleep mode - Satellite T110-10x

    Hi, Everything works fine, wireless connected. After sleep mode - it fails to connect although it detects my wireless network. I've tried the latest Realtek driver, still no good. I've verified that my setup is not to turn down wireless in the power

  • Pulling my hair out: Change format from date to number format?

    I was recently sent a formatted Excel spreadsheet in which to enter my own numbers.  The format is date and duration, but the last column is the total number of hours and minutes converted into decimals, e.g. 3hrs. 30mins. = 3.5 hours. It was going f

  • Rlim_fd_max Kernel Parameter on Solaris 9

    I am trying to install Oracle Application Server 10g Release 2 on Solaris 9. The installation errors out on the "Select Configuration Options" screen with the following error: "Oracle Application Server 10g Web Cache requires the Kernel Parameter rli

  • Picking & Delivery Related Issue

    Hi, Planning strategy used 40 The placed Sales Order does not allow delivery even when the Stocks are available, giving and error stating “Only 0 stocks of material xxxxx available” There is a future dated Sales Order, when trying to expedite the ord