How truncate table affect index?

HI, all,
I have a question about indexes in a table. If I truncate the table and reload data, do the indexes in the table still valid?
From documentation:
“a table is truncated, all associated indexes are also truncated.”
What does that mean?
Do I need to recreate index every time I truncate table?
Thanks a lot.

No, it's just what it says: it truncates the index, just like it truncates the table. You do not have to recreate the table, nor the index.
Truncating is deleting without the possibility of a rollback.

Similar Messages

  • Interrupted TRUNCATE TABLE command

    Hello,
    I've made very dangerous mistake today: TRUNCATE TABLE on production database. :-(
    But in several seconds (2 or 3), I managed to break the operation (Before the execution ended).
    It was quite a big table, now (after the accident) there are more then 32 million records.
    We need to know, are there any records deleted?
    We have no proper backup, to compare the records with it.
    And I could not find any in-depth description of how TRUNCATE works.
    Please can you:
    1. Tell, about any method to check if there are deleted records?
    2. Link, to any resource, where I can read in details, about how TRUNCATE TABLE works.
    Thanks, in advance, for help

    My understanding is that the TRUNCATE TABLE table statement is atomic. It either fails or succeeds. Truncates all rows or no rows at all. Therefore if you interrupt a TRUNCATE TABLE statement your table should remain in its original state.
    This can be shown below:
    SQL > CREATE TABLE TEST AS SELECT * FROM ALL_OBJECTS;
    Table created.
    SQL > INSERT INTO TEST SELECT * FROM TEST;
    12421 rows created.
    SQL > INSERT INTO TEST SELECT * FROM TEST;
    24842 rows created.
    SQL > INSERT INTO TEST SELECT * FROM TEST;
    49684 rows created.
    SQL > INSERT INTO TEST SELECT * FROM TEST;
    99368 rows created.
    SQL > INSERT INTO TEST SELECT * FROM TEST;
    198736 rows created.
    SQL > INSERT INTO TEST SELECT * FROM TEST;
    397472 rows created.
    SQL > INSERT INTO TEST SELECT * FROM TEST;
    794944 rows created.
    SQL > INSERT INTO TEST SELECT * FROM TEST;
    1589888 rows created.
    SQL > SELECT COUNT(*) FROM TEST;
      COUNT(*)
       3179776
    SQL > TRUNCATE TABLE TEST;
    ^C
    H:\>sqlplus /@testdb
    SQL*Plus: Release 10.2.0.4.0 - Production on Mon Aug 3 08:20:11 2009
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Enter password:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL > SELECT COUNT(*) FROM TEST;
      COUNT(*)
       3179776HTH!

  • How index affected by truncate table

    HI, all,
    I have a question about indexes in a table. If I truncate the table and reload data, do the indexes in the table still valid?
    From documentation:
    “a table is truncated, all associated indexes are also truncated.”
    What does that mean?
    Do I need to recreate index every time I truncate table?
    Thanks a lot.

    When you truncate a table, you are removing all the data from the table but leaving the structure of the table intact. Logically, the same thing must happen to the index-- all the index data must be removed (since there are no longer any entries in the table), but the structure of the index remains intact.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Truncate TABLE PSA table-index part

    Dear all,
    I have a doubt about the truncate action on BW of PSA table.
    To speed the activity and empty some tablespace I have truncated for example the PSA /BIC/B0000025000 and all table and index parts have emptied, so, on the contrary of disk space, the table part and index part from 00001 to 00050 for example are no longer used and the next uploads creates partition 00051.
    The question is: I must drop all index and table part previously emptied?
    If yes a must keep in mind some indications?
    I could have some problem to leave this table and index part empty, for example about performance or inconsistence?
    There is some contraindication to truncate PSA?
    Can i use program 'RSAR_CLEANUP_PSA_DIRECTORY' to delete its?
    Thanks for your help.
    Best Regards
    Daniele

    Hi Kaushal,
    thanks for your answer.
    I have executed program mentioned in oss note 733371.
    After the execution of RSAR_PSA_CLEANUP_DIRECTORY
    some errors have found:
    in the head of log there are this two entries:
    Fatal error occured, DO NOT USE correct option
    For errors 'wrongly present in partition' refer to NOTE 849857 / 992248
    the rest of log this kind of errors:
    Request : ODSR_47KKTL3NMVNZPGY17C4POEYAV  missed in partition  0015
    The oss note 849857 is for release lower of mine, the note 992248 is for my release, its talks about a program 'SAP_PSA_ZEROCORRECT' imported automatically with SP 11, i have level 13 os SP BI but i didn't find that program,
    do you have some idea about that?
    After execution of report RSAR_PSA_CLEANUP_DEFINITION (only check)
    I have this error:
    No DDIC Table Exists for PSA: ZEDS_NOT_T_BA Vrs. 000
    There Is No Active DDIC Table: /BIC/B0000852000
    Do you think that if i run RSAR_PSA_CLEANUP_DEFINITION  with repair object i can resolve all my problem visualized for report RSAR_PSA_CLEANUP_DIRECTORY either? Or before in must execute RSAR_PSA_CLEANUP_DIRECTORY whit repair option?
    Thanks for your help
    Ciao

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

  • How   to  find  global  index  in partition table

    Hi guys ,
    need one help
    How to find global index on partition table
    How to find local index on partition table
    Need query
    Thanks in advance
    Edited by: nav on Feb 17, 2012 6:51 AM

    nav wrote:
    Hi Solomon,
    so I have to identify partition & index are created or not,
    also I have check the status of index ( both global and local)So what's the problem? Table/index partition is an object, so you can query DBA_OBJECTS:
    SELECT  SUBOBJECT_NAME,
            CREATED
      FROM  DBA_OBJECTS
      WHERE OWNER = partitioned-table-owner
        AND OBJECT_NAME = partitioned-table-name
        AND CREATED >= TRUNC(SYSDATE)
    /This will give you partitions created today. So if you run this right after your job (I hope your job doen't run too close to midnight), you'll get table partition name your job created. Same logic can be applied to indexes.
    SY.

  • How to create table(s)/indexes on a new database from an existing database

    Hello all - I need some help in finishing a task, quick response is really appreciated
    So, I have a new database that needs creation of tables including indexes and objects for two different tablespaces called CDS1 and CSD2. I have created these tablespaces and datafiles associated with them. I need some help just to create these tables and indexes from an existing database without copying any of its contents. How can I achieve this, these are 2 different servers at different locations. Can somebody give me step by step instruction - would greatly appreciate it !
    Thanks,
    Vikas

    9876543210 wrote:
    Hello all - I need some help in finishing a task, quick response is really appreciated
    So, I have a new database that needs creation of tables including indexes and objects for two different tablespaces called CDS1 and CSD2. I have created these tablespaces and datafiles associated with them. I need some help just to create these tables and indexes from an existing database without copying any of its contents. How can I achieve this, these are 2 different servers at different locations. Can somebody give me step by step instruction - would greatly appreciate it !
    Thanks,
    Vikas
    exp help=yes
    exp username/password rows=no
    How do I ask a question on the forums?
    https://forums.oracle.com/message/9362002#9362002

  • How to handle the MISSING STATISTICS:Table or Index has no optimizer stats

    Dear All,
    For some of our recently created Ztables, we have been receiving an error message of MISSING STATISTICS in the system saying that Table or Index has no optimizer statistics. To solve the problem, when I go for creating an index with the key fields of the table, I receive a message that these fields are already there in the index 0 (primary index).
    Pls advice how to solve this issue.
    Regards,
    Alok.

    Hi friend,
    Please delete all primary and secondary indexes and redo creation of index. Now u will surely be able to create it.

  • How to create  table level index.

    Hi All,
           I have written a program for c-form tracking , where i used purchasing tables like EKBE , EKKO and accounting tables , BSEG and BKPF.BSEG isa cluster table . it is taking execution time more at database level , so if i create a index on tables is it useful to increase the performance  if so please inform me how do i create index .
    please it is very urgent .

    Hi Shilpa,
    Creating the index will solve the purpose if your select statements are going to use that filed for which you are going to create the index.
    Instead of using the cluster table like Bseg try to find the alternative tables for your requirement, i think that will definitely improve the performance.
    Steps for creating the index are as follows
    Yo have to use trx SE11 into Dev system.
    Enter the database table name and press
    Display -> Indexes -> Create
    Enter index name.
    Choose Maintain logon language.
    Enter short description and index fields.
    Then press save and create the request to transport the index to QA and
    PRD.
    Then press activate.
    Regards,
    Viveks

  • How Find space Used by Tables and Indexes

    Dear All(s)
    How i check space used (and number of rows) by each table and index in schema. ( can i check current space utilization and sysdate-date past in time)
    How i can check used, and free space for each database and tablespace.
    Thanks

    You can always use the search feature
    anyway
    how to calculate the percentage of free space for a table in Oracle
    Re: incorrect free space in dba_free_space
    These links could give you all the necessary info

  • How to create secondry index on database table

    how to create secondry index on database table

    Hi
    By trx SE11:
    - Choose your table and press CHANGE ICON, so INDEX
    When you create an index you should consider if your index is contained in another index.
    If the fields of your index are:
    - FIELD1, FLIED2, FIELD3
    ...it'll be triggered only if the select is:
    SELECT * FROM <TABLE> WHERE FIELD1
                            AND FIELD2
                            AND FIELD3
    A select like this
    SELECT * FROM <TABLE> WHERE FIELD1
                            AND FIELD3
                            AND FIELD2
    doesn't use your index.
    Max

  • How to partition tables and indexes in this scenario?

    So our situation is pretty simple. We have 3 tables.
    A, B and C
    the model is A->>B->>C
    Currently A, B and C are range partitioned on a key created_date however it's typical that only C is every qualfied with created date. There is a foreign key from B -> A and C -> B
    we have many queries where the data is identified by state that is indexed currently non partitioned on columns in A ... there are also indexes on the foreign keys that get from C -> B -> A. Again these are non partitioned indexes at this time.
    It is typical that we qualify A on either account or user or both. There are indexes (non partitioned) on these
    We have a problem now because many of the queries use leading wildcards ie. account like '%ACCOUNT' etc. This often results in large full table scans. Our solution has been to remove the leading wildcard but this isn't always possible.
    We are wondering how we can benefit from partitioning and or sub partitioning table A. since it's partitioned on created_date but rarely qualify by that.
    We are also wondering where and how we can benefit from either global partitioned index or local partitioned indexes on tables A. We suspect that the index on the foreign key from C to B could be a local partitioned index.
    I am also wondering what impact pushing the state from A that's used to qualify A down to C would have any advantage.
    C is the table that currently we qualify with the partition key so I figure if you also pushed down the state from A that's used to qualify the set of C's we want based on the set of B's we want based on the set of A thru qualfying on columns within A.
    If we push down some of those values to C and simply use C when filtering I'm wondering what the plans will look like compared to having to work all the way up from the bottom to the top before it begins qualifying A.
    Edited by: steffi on Jan 14, 2011 11:36 PM

    We are wondering how we can benefit from partitioning and or sub partitioning table A. since it's partitioned on >created_date but rarely qualify by that. Very good question. Why did you partition on it? You will never have INSERTS on these partitions, but maybe deletes and updates? The only advantage (I can think of) would be to set these partitions in a read only tablespace to ease backup... but that's a weired reason.
    we have many queries where the data is identified by state that is indexed currently non partitioned on columns in >A ... there are also indexes on the foreign keys that get from C -> B -> A. Again these are non partitioned indexes at >this time.Of course. Why should they be partitioned by Create_date?
    It is typical that we qualify A on either account or user or both. There are indexes (non partitioned) on these
    We have a problem now because many of the queries use leading wildcards ie. account like '%ACCOUNT' etc. This >often results in large full table scans. Our solution has been to remove the leading wildcard but this isn't always possible.I would suspect full index scan. Isn't it?
    We are also wondering where and how we can benefit from either global partitioned index or local partitioned >indexes on tables A. We suspect that the index on the foreign key from C to B could be a local partitioned index.As A is not accessed by any partition, why should C and B profit? You should look to partition by the key you are using to access. But, you are looking to tune your SQLs where the access is like '%ACCOUNT' on A. Then when there is a match. ORACLE joins via your index and nested loop (right?) to B and C.
    I am also wondering what impact pushing the state from A that's used to qualify A down to C would have any >advantage.Why should it. It just makes the table and indexes larger => more IO.
    C is the table that currently we qualify with the partition key so I figure if you also pushed down the state from A >that's used to qualify the set of C's we want based on the set of B's we want based on the set of A thru qualfying >on columns within A.If the access from A to C would be .. AND A.CREATE_DATE =C.CREATE_DATE and c.key like '%what I want%' which does not qualifify for a FK ;-) then, as that could be resulting in a partition scan, you could "profit". But, I'm sure that's not your model.
    If we push down some of those values to C and simply use C when filtering I'm wondering what the plans will look >like compared to having to work all the way up from the bottom to the top before it begins qualifying A.So you want to denormalize A,B,C and into one table? With the same access is like '%ACCOUNT' you would get a full scan on an index as before, just the objects would be larger due to redundance and harder to maintain. In the end you would have a bad and slower design.
    Maybe you explain what the problem is.
    Full index scan can not be avoided, but that can be made faster by e.g. parallel query, and then the join to B and C should be a "snip" if you just identify a small subset of rows in these tables.

  • How many table are affected when sales order creation(O2C)

    Hi all,
             HOw many table are affected when sales order creation, can any one please help ,and please give me a description indepth please please. I know some of the table affected
    Thanks&Regrads,
    Surya

    Hi Kantur Shekar madhuri,
    Would you confirm the whether in your schedule line category is activated for "Product Allocation" or not.
    if not please activate and re run your scenario.
    Regards
    Arun

  • How to get return type as Table of Index by BINAR from Procedure using JDBC

    Hi,
    We have stored procedure which takes Varchar as input and rerurn muiltiple recored of type Table of index by BINARY
    We created the procedure with in a package, its header part like below:
    CREATE OR REPLACE PACKAGE emp_pkid_pkg
    AS
    TYPE r_emp IS RECORD ( employe_profile_id NUMBER
    , client_profile_id VARCHAR2(240)
    , email VARCHAR2(240)
    , terms_acp VARCHAR2(1)
    TYPE tp_emp_profile IS TABLE OF r_emp INDEX BY BINARY_INTEGER;
    PROCEDURE er_employe_prov_profile ( e_inxid employe_provision_instance.inxid%TYPE
    , e_emp_recs OUT tp_emp_profile
    END emp_pkid_pkg;
    This procedure has body part, wich has origial business logic like below.
    CREATE OR REPLACE PACKAGE BODY emp_pkid_pkg
    AS
    PROCEDURE pr_customer_prov_profile ( e_inxid employe_provision_instance.inxid%TYPE
    , e_emp_recs OUT tp_customer_provision_profile
    IS
    CURSOR c_emp_prov_instance ( c_guid employe_provision_instance.guid%TYPE )
    etc ...
    END emp_pkid_pkg;
    We could execute the below script from oracle client tool and get the response.
    DECLARE
    e_cust emp_pkid_pkg.tp_emp_profile;
    BEGIN
    emp_pkid_pkg.er_employe_prov_profile ( 'ef45t6543y98'
    , e_cust
    FOR i in e_cust.FIRST..e_cust.LAST LOOP
    DBMS_OUTPUT.PUT_LINE ( e_cust(i).employe_profile_id
    ||'#'|| e_cust(i).client_customer_id
    ||'#'|| e_cust(i).email
    ||'#'|| e_cust(i).term_acp);
    END LOOP;
    END;
    We have requirement to get the results from procedure usind JDBC callable statement call.
    We have tried to call the procedure via JDBC callable statement but it didn't work.
    We have constructed it like the following. It was throwing error "java.sql.SQLException: invalid column type: emp_pkid_pkg.tp_emp_profile
    CallableStatement cs2 = con.prepareCall("{call emp_pkid_pkg.er_employe_prov_profile(?,?)}");
    cs2.registerOutParameter(2, OracleTypes.CURSOR, emp_pkid_pkg.tp_emp_profile);
    cs2.setString(1,empId);
    Not sure whether I am doing the logic correctly. But i tryed with diff type. Still am getting same error like above.
    Please point me to the correct approach.
    Thanks
    Edited by: 921689 on 18-Mar-2012 17:20

    >
    We have requirement to get the results from procedure usind JDBC callable statement call.
    >
    Can't be done - the reason has nothing to do with JDBC so you are in the wrong forum.
    Repost in the PL/SQL forum and I can give you an example of what you have to do
    PL/SQL
    First the TYPEs you defined are PL/SQL types so can't be referenced outside PL/SQL; you need to define SQL types.
    Second you will need to use a procedure that returns a REF CURSOR or is a PIPELINED procedure. Since your procedure doesn't fall into either category you can't use it with JDBC to do what you want.
    If your query was a PIPELINED function then you could simply query it like it was a table. I have a PIPELINED function name 'get_emp' so this works.
    select * from table(get_emp(30));Post in the PL/SQL forum and I can give you the code for the procedure. I'm not going to clutter up this forum with inappropriate material.

  • How to find affected tables in the database

    Hi Friends,
    Is there any way to find the tables affected in the database when book a trade in the Application in Oracle. Please help me to find the affected tables.
    Thanks,
    ragu.
    Edited by: user533548 on Apr 3, 2009 5:08 AM
    Edited by: user533548 on Apr 3, 2009 5:13 AM

    Hi Karthick_Arp,
    You take any application for example when you book details about a new employee the rows will be affected in the database we generally use the empid to identify
    what are the tables affected is there any way like this when you book a trade in the Application to find what are all the tables affected in the database.I think that
    you have understand my question.
    Thanks,
    ragu.
    Edited by: user533548 on Apr 3, 2009 5:09 AM
    Edited by: user533548 on Apr 3, 2009 5:13 AM

Maybe you are looking for

  • Customer is not assigned to a partner function

    Hi Experts, I'm encountering the same error. When I view the Customer and click Customer Partner Functions, system throws a message Customer SP0003 is not assigned to a partner function How do I assign my newly created Customer to a Partner Function

  • Ipad Air 2 die ?

    What a shame for Apple !!! I am totally disappointed. My Ipad Air 2 was used until 11.30 p.m. last night and the battery level was about 50%. But this morning I can not turn it on. I have tried to charge it but there is no positive signal. I have jus

  • Thinkpad X201 & KDE: KDE doesn't get info on display brightness

    In KDE, I can adjust my screen brightness with both the Fn-{Home,End} keys, and with Battery Monitor widget. Both methods work normally. However, these methods work independent of each other: if the Battery Monitor shows 100% screen brightness and I

  • LTA claim in ESS

    In ESS, journey start date , end date details are not coming in LTA claim. Plz explain LTA configuration in R/3 for ESS display. Would appreciate help.

  • Exception when trying to update sequence numbers

    I'm using TopLink 9.0.4 with Weblogic 8.1 sp2, MS SQL Server 7. I am getting an exception when Toplink attempts to update a sequence number. The SQL it produces looks good, but for some reason, the method: oracle.toplink.internal.sequencing.Sequencin