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

Similar Messages

  • 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.

  • 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

  • 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.

  • Truncate table loses privs on table...

    Oracle11g/RHEL5
    Hi,
    We have a table that is inserted into a then deleted every so often. The current method that was being used to remove the rows was the TRUNCATE TABLE ption. However, we found out that when that statement is issued, that any user that had privs on that table, no longer work even after it is re-created. So it looks like the next option is to used the DELETE * from table_name. However, that is not good for performance and undo. This table is about 300,000 rows and will grow in the future. How could we get around this issue?
    Thanks.

    Hi,
    JrOraDBA wrote:
    Oracle11g/RHEL5
    We have a table that is inserted into a then deleted every so often. The current method that was being used to remove the rows was the TRUNCATE TABLE ption. However, we found out that when that statement is issued, that any user that had privs on that table, no longer work even after it is re-created. You must have done something else. TRUNCATE TABLE does change privileges.
    What do you mean by "after it is re-created"? You don't have to issue another CREATE statement after TRUNCATE TABLE.
    Do you mean after re-populating the table? Do you mean that other users, who did have privileges, can still DESCRIBE the table right after it is TRUNCATEd, but they can't do anything with it after an INSERTs have been done?
    I suspect you DROPped the table at some point.
    Double-check that the problem exists when all you do is TRUNCATE TABLE.
    Post a script that re-creates the problem. There's no need to include lots of data: one column and one row will show the problem just fine.

  • Truncate Table

    Folks,
    I am creating an application for users to enter various parameters to be used in generating a mass of reports. This is replacing an existing MS Access application that has an option to truncate the entire table's contents.
    How do I invoke a simple truncate table function rather than require the user to individually delete hundreds of rows of data?
    Thanks. Bruce

    Bruce,
    How about a PL/SQL page process with code like this, assuming the table name will have to be derived or constructed for individual users:  declare q varchar2(30);
      begin
        q := 'BASE_NAME_'||:APP_USER; -- example
        execute immediate 'truncate table '||q;
      end;Scott

  • TRUNCATE TABLE  does not work in procedure

    Hi Friends,
    I create a procedure that have a command TRUNCATE TABLE errdbg;
    It use to record data processing information. It iworks in SQLPLUS by manually.
    I put it in procedure and get message as
    Warning: Package Body created with compilation errors.
    SQL> show error;
    Errors for PACKAGE BODY DATALOAD:
    LINE/COL ERROR
    172/10 PLS-00103: Encountered the symbol "TABLE" when expecting one of
    the following:
    := . ( @ % ;
    The symbol ":= was inserted before "TABLE" to continue.
    How to use TRUNCATE command in procedure?
    I can use delete. but it is not good for table space resused based on book.
    Thanks
    JIm

    You can't use DDL in pl/sql unless you use it with execute immediate
    e.g.,
    execute immediate 'truncate table errdbg' ;

  • TRUNCATE TABLE NOT WORKING AFTER DROPPING CONSTRAINTS

    Hi,
    I have a table with a foreign key constraint. I know you can't truncate tables when there are foreign key constraints. So I drop the constraints before running the TRUNCATE TABLE command. But SQL Server is still stating there are foreign key constraints
    even after they have just been dropped.
    When I use SQL Server Management Studio to generate a drop & create script on this table or any other table with an FK consttaint, the generated script fails stating that there are still foreign key constraints??
    I have the same problem for every table that has FK constraints, for those without FK, TRUNCATE table works without issues.
    The end goal is to reset the identity value of the primary key. Since DBCC does not work on Azure, TRUNCATE TABLE is the only way left, especially if you can't even drop and recreate tables with FK constraints.
    What am I missing here?
    Peter

    Hi,
    Thanks for posting here.
    TRUNCATE TABLE is similar to the DELETE statement with no WHERE clause; however, TRUNCATE TABLE is faster and uses fewer system and transaction log resources.
    TRUNCATE TABLE removes all rows from a table, but the table structure and its columns, constraints, indexes, and so on remain. To remove the table definition in addition to its data, use the DROP TABLE statement.
    If the table contains an identity column, the counter for that column is reset to the seed value defined for the column. If no seed was defined, the default value 1 is used. To retain the identity counter, use DELETE instead.
    Restrictions
    You cannot use TRUNCATE TABLE on tables that:
    •Are referenced by a FOREIGN KEY constraint. (You can truncate a table that has a foreign key that references itself.)
    •Participate in an indexed view.
    •Are published by using transactional replication or merge replication.
    For tables with one or more of these characteristics, use the DELETE statement instead.
    TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions. For more information, see CREATE TRIGGER (Transact-SQL).
    Truncating Large Tables
    Microsoft SQL Server has the ability to drop or truncate tables that have more than 128 extents without holding simultaneous locks on all the extents required for the drop.
    Permissions--------------------------------------------------------------------------------
     The minimum permission required is ALTER on table_name. TRUNCATE TABLE permissions default to the table owner, members of the sysadmin fixed server role, and the db_owner and db_ddladmin fixed database roles, and are not transferable. However, you
    can incorporate the TRUNCATE TABLE statement within a module, such as a stored procedure, and grant appropriate permissions to the module using the EXECUTE AS clause.
    You cannot truncate a table which has an FK constraint on it.
    Typically my process for this is:
    Drop the constraints
    Trunc the table
    Recreate the constraints.
    Hope this helps you.
    Girish Prajwal

  • ORA-01502: Index or Partition is in unusable status. while truncating table

    Hi All,
    One of our Devlopers compalined that he is getting ORA-01502 : Index or partition is unusable status while truncating the a table in our Dataware house production database. He is using the following commands.
    Alter index <index_name> unusable;
    Truncate table <table_name> ;
    He is running a scripts to truncate each table and ecah time he is passing the table name as an input parameter to script. He is using same method to truncate four tables each having a BITMAP and a REGULAR index. For two tables every thing is working fine, but for other two tables the he is getting ORA-01502 for BITMAP indexes. It a weekly process and every week he is getting the same issue. I checkd the Index status, they are in valid status only.
    For a work around I have created a table with BITMAP and regular index in our dev database. made the indexes unusable, checked their status. I truncated the table. Importent thing here is the Indexes are becoming vaild when I truncate the table.
    I suspect that my devloper's Indexes were already in unusable status (before he use the command ALTER INDEX), when he truncated the table, oracle trying to validate the index and throwing the error ORA-01502 because the Indexes are in unusabel statsu for a while.
    I tried searching for the mechanism of truncate table command and its effect on Indexes. But I did not find any luck, no one is speaking about index when truncating the table. Can any one please help me????
    Sorry for lengthy post. Any help is greatly appriciated and I thank every one in advance.

    DDL for Indexes getting ORA-01502 error
    CREATE BITMAP INDEX DWHMGR.ACT_TXN_LN_STG_01_XN3 ON DWHMGR.ACCT_TXN_LINE_TERM_BAL_STG_01 (TERM_BAL_CD ASC) TABLESPACE "BALFD_INX_04" NOLOGGING PCTFREE 1 INITRANS 2 MAXTRANS 255 STORAGE
    ( INITIAL 8M NEXT 8M MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 BUFFER_POOL DEFAULT );
    CREATE BITMAP INDEX DWHMGR.ACCT_TERM_BAL_STG_01_XN3 ON DWHMGR.ACCT_TERM_BAL_STG_01 TERM_BAL_CD ASC) TABLESPACE "BALFD_INX_04" NOLOGGING PCTFREE 1 INITRANS 2 MAXTRANS 255 STORAGE
    ( INITIAL 8M NEXT 8M MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 BUFFER_POOL DEFAULT );
    Indexes that have no issues.
    CREATE INDEX DWHMGR.ACCT_TERM_BAL_STG_01_XN2 ON DWHMGR.ACCT_TERM_BAL_STG_01 (ACCT_REF_NB ASC) TABLESPACE "BALFD_INX_04" NOLOGGING PCTFREE 1 INITRANS 2 MAXTRANS 255 STORAGE (INITIAL 8M
    NEXT 8M MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 BUFFER_POOL DEFAULT );
    CREATE BITMAP INDEX DWHMGR.ACCT_PRC_STG_01_XN1 ON DWHMGR.ACCT_PRC_STG_01 (ACCT_ORG_CD ASC) TABLESPACE "BALFD_INX_04" NOLOGGING PCTFREE 1 INITRANS 2 MAXTRANS 255 STORAGE ( INITIAL 8M
    NEXT 8M MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 BUFFER_POOL DEFAULT );
    Please look at the DDL of the indexes and let me know if you need any other information.

  • Reg: Truncate table command in Stored Procedures

    Hi All,
    I wrote one procedure in which i used 'Truncate Table command' and while compiling I am getting an error. I searched on google but again many queries has been asked there but no suitable solution is there. So please help me in understanding this matter.I will be really obliged of you.
    Gursimran Singh

    Hi thanks for your reply. The error I am getting is here
    PLS-00103: Encountered the symbol "TABLE" when expecting one of the following:
    := . ( @ % ;
    The symbol ":= was inserted before "TABLE" to continue.
    I appreciate your step to use 'execute immediate 'truncate table table_name';. but the thing is that the system is not allowing my to use TRUNCATE than how come i use the above expression.
    Second thing is that there is no error in syntax, everything is fit and fine.
    Gursimran

  • Can grant truncate table permission to a user?

    Whether can grant  truncate table permission to a user separately.
    I know that the role db_ddladmin can do,but the create,alter and drop permissions will be granted the same time(These permissions are not what we want to
    grant to user).
    Is there any solution?
    Best regards!!
    If you haven't all the things you want,be grateful for the things you don't have that you didn't want.

    You can't grant truncate because for whatever reason, that permission doesn't exist.  What you can do is use a stored procedure and use EXECUTE AS OWNER to get around it.
    create database foo
    go
    create login foobar with password = 'alkdsfji9eorngv';
    go
    use foo
    go
    create user foobar from login foobar;
    go
    create table test(rowid int identity)
    go
    insert into test default values;
    go
    select * from test
    go
    create procedure dbo.truncate_test
    with execute as owner
    as
    truncate table test
    go
    grant execute on dbo.truncate_test to foobar
    go
    execute as login='foobar'
    execute dbo.truncate_test
    revert
    go
    select * from test
    go
    use master
    go
    drop database foo
    drop login foobar
    This keeps your database safe and allows you to grant execute on the truncate procedure to allow them to truncate the table.Jonathan Kehayias
    http://sqlblog.com/blogs/jonathan_kehayias/
    http://www.twitter.com/SQLSarg
    http://www.sqlclr.net/
    Please click the Mark as Answer button if a post solves your problem!

  • I want to know when we issue truncate table statement in oracle .

    i want to know when we issue truncate table statement in oracle .No log will be write in redo log .But we can recover data using flashback or scn.I want to know where is the actually truncate table statement log is stored in oracle database.Please explain me in detail step by step .

    Hi,
    I have truncated table after that i have restored that data.See below the example.I want to know from where it's restored.
    From which log file it's restored.
    create table mytab (n number, x varchar2(90), d date);
    alter table mytab enable row movement;
    Table altered.
    SQL> insert into mytab values (1,'Monsters of Folk',sysdate);
    1 row created.
    SQL> insert into mytab values (2,'The Frames',sysdate-1/24);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select CURRENT_SCN from v$database;
    CURRENT_SCN
    972383
    SQL> select * from mytab;
    N
    X
    D
    1
    Monsters of Folk
    30-DEC-12
    2
    The Frames
    30-DEC-12
    N
    X
    D
    SQL> set lines 10000
    SQL> /
    N X D
    1 Monsters of Folk 30-DEC-12
    2 The Frames 30-DEC-12
    SQL> select to_char(sysdate,'yyyymmdd hh24:mi:ss') from dual;
    TO_CHAR(SYSDATE,'
    20121230 09:29:24
    SQL> set timing on
    SQL> truncate table mytab;
    Table truncated.
    Elapsed: 00:00:15.75
    SQL> select * from mytab as of timestamp TO_TIMESTAMP('20121230 09:29:24','yyyymmdd hh24:mi:ss');
    N X D
    1 Monsters of Folk 30-DEC-12
    2 The Frames 30-DEC-12
    Elapsed: 00:00:00.28
    SQL> insert into mytab select * from mytab as of timestamp TO_TIMESTAMP('20121230 09:29:24','yyyymmdd hh24:mi:ss');
    2 rows created.
    Elapsed: 00:00:00.01
    SQL>

  • Data factory truncate table

    I'm copying data from table storage to a sql azure database. Im using ADF. Im able to setup the process. I want to schedule a recurring meeting and add a truncate table. How do you delete all records in the sql azure database?

    Hi Julius,
    You could use a Stored Procedure to handle the delete and insert, in the Sink (Destination) side of the Copy Activity. 
    Borrowing from another recent reply:
    You can specify the property "SqlWriterStoredProcedureName" and "SqlWriterTableType" in SqlSink, and add the merge logic in your own stored procedure. Notice that don't use a simple delete operation in the stored procedure, as it may
    be called several times in a single Copy.
    For more information about how to use this feature, refer to this post.
    and the Azure documentation here http://azure.microsoft.com/en-us/documentation/articles/data-factory-copy-activity-advanced/
    Thanks, Jason
    Didn't get enough help here? Submit a case with the Microsoft Customer Support teams for deeper investigation - Azure service support: https://manage.windowsazure.com/?getsupport=true For on Premise software support go here instead: http://support.microsoft.com/select/default.aspx?target=assistance

Maybe you are looking for

  • Can I connect the Airport Express to a TV and watch the screen of my Mac on the TV?

    Could I know if I can connect the Airport Express to the TV and watch the screen of my Mac or iPad or iPhone... On the TV?

  • When done editing, picture turns black

    after I edit a picture, when I hit done, the picture turns completely black (both the thumbnail and the actual pic). Plus during editing effects (sepia tone, etc. are not available - no preview pic is offered. any help will be appreciated

  • ObjectId@: How to drawn the ObjectId@ token into the Crystal Report????

    In all documentation about the tokens to be used in order to have the right document published in CR, there's no reference how SBO draw the the ObjectId@ into the report. In the standard CR reports SAP delivers with SBO, the DocKey@ is drawn by a for

  • Installing latest Adobe Flash player

    Just tonight I uninstalled the old version of Adobe Flash Player (I used Adobe's Flash uninstaller utility). Then I downloaded and installed the latest version of the Flash Player. Everything looks fine, but but one thing confuses me. On my desktop,

  • Error wtih database connection string

    Hi, I am having Oralce 9i AS on windows. Application which we use is forms and reports. We have customised the login screen .Which will ask for only 1. User name 2. Password Upto now it was working fine but from last few days some of my clients whos