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

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

  • Raising ora-01426 error while truncating table

    Hi,
    We have a procedure which executes in the following process for few set of tabls
    1. disables the constraints
    2. truncating the tables
    3. enabling the constraints
    but after processing for 5 tables, while truncating the error throws
    BEGIN <procedure name >; END;
    ERROR at line 1:
    ORA-01426: numeric overflow
    ORA-06512: at "<procedurename> ", line 33
    ORA-06512: at line 1
    this line 33 point to execute immeidate 'truncate table < table name>
    Can i know what would be reason for throwing ' numeric overflow' error while truncating table..
    Thanks in advance

    user9080289 wrote:
    thanks.
    My oracle verision is 11gThen you could have the bug described there. Follow the instruction how to workaround (monitoring flush, set stats to low value) or apply the patch #8226471.
    Nicolas.

  • 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 related questions

    Hi Folks,
    Environment: 10g Rel 2
    I am trying to prove the following two points by way of experimentation
    a, The truncate table operation will reset the high water mark (HWM) to the first usable data block in the table segment
    # Take a HWM snap shot before the truncate operation
    select a.BLOCKS - b.EMPTY_BLOCKS -1 HWM
    from
      (SELECT BLOCKS
       FROM   DBA_SEGMENTS
       WHERE  OWNER=UPPER('JIM') AND SEGMENT_NAME = UPPER('EMPLOYEES')) a,
       (SELECT EMPTY_BLOCKS
        FROM   DBA_TABLES
        WHERE  OWNER=UPPER('JIM') AND TABLE_NAME = UPPER('EMPLOYEES')) b;Output: 7
    truncate table JIM.EMPLOYEES;
    Re ran the above code and got the same result (i.e. 7 blocks). I was expecting to see 0 blocks instead? Is the above query the right method of
    finding the HWM?
    b, The truncate operation will also truncate the corresponding indexes for the table
    Q, Is there a view that will show all the index values of the table? These values will probably be meaningless, but I would like to see them before
    and after the truncate operation.
    Thanks
    rogers42

    a) If you would have read on the empty_blocks column in dba_tables, you would have known it is populated by dbms_stats.
    Did you run dbms_stats.analyze_table?
    b)
    There is no such view.
    All dictionary views are documented in the view DICT and the online documentation.
    Sybrand Bakker

  • 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

  • Truncate table will delete the corresponding LOB segment of table or not ?

    Hi All,
    I have few table with LOB segments, if i fire the truncate table on those table will it purge the LOB segment as well ?
    Approximately how much time will take to truncate 100gb LOB segments.
    Thanks

    903787 wrote:
    Hi ,
    1.Truncate will delete the LOB segment or not ?It won't delete the LOB segments but it should release most of the allocated space.
    >
    2.To reclaim space we need to run the below command, is it correct ?
    ALTER TABLE <table_name> MODIFY LOB (LOB_COLUMN) (SHRINK SPACE);
    Should not be needed in 11.2:
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0      Production
    TNS for 32-bit Windows: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    SQL> select count(*) from user_segments;
      COUNT(*)
             0
    SQL>
    SQL> create table t(x clob);
    Table created.
    SQL> select segment_name, segment_type, bytes
      2  from user_segments;
    SEGMENT_NAME                             SEGMENT_TYPE            BYTES
    T                                        TABLE                   65536
    SYS_IL0000030908C00001$$                 LOBINDEX                65536
    SYS_LOB0000030908C00001$$                LOBSEGMENT              65536
    SQL>
    SQL> insert into t select lpad(segment_name,8192) from dba_segments;
    6312 rows created.
    SQL> commit;
    Commit complete.
    SQL>
    SQL> select segment_name, segment_type, bytes
      2  from user_segments;
    SEGMENT_NAME                             SEGMENT_TYPE            BYTES
    T                                        TABLE                  393216
    SYS_IL0000030908C00001$$                 LOBINDEX                65536
    SYS_LOB0000030908C00001$$                LOBSEGMENT           53477376
    SQL>
    SQL> truncate table t;
    Table truncated.
    SQL>
    SQL> select segment_name, segment_type, bytes
      2  from user_segments;
    SEGMENT_NAME                             SEGMENT_TYPE            BYTES
    T                                        TABLE                   65536
    SYS_IL0000030908C00001$$                 LOBINDEX                65536
    SYS_LOB0000030908C00001$$                LOBSEGMENT              65536
    SQL>
    SQL> alter table t modify lob(x) (shrink space);
    Table altered.
    SQL>
    SQL> select segment_name, segment_type, bytes
      2  from user_segments;
    SEGMENT_NAME                             SEGMENT_TYPE            BYTES
    T                                        TABLE                   65536
    SYS_IL0000030908C00001$$                 LOBINDEX                65536
    SYS_LOB0000030908C00001$$                LOBSEGMENT              65536
    SQL>

  • Truncate table taking too much time

    hi guys,
    thnks in advince.......
    oracle version is =9.2.0.5.0
    os/ version =SunOS Ganesha1 5.9 Generic_122300-05 sun4u sparc SUNW,Sun-Fire-V890
    application people-soft
    version=8.4
    every thing is running fine from last week .
    whenever process executed like billing ,d_dairy.
    it selected some temporary tables and start truncate tables it takes 5 mint to 8 mint even table has 0 rows.
    if more then one users executed process but diff process it comes in lock ..
    regs
    deep..

    Hi,
    Here iam sending details of technical settings.
    Name                 ACCTIT                          Transparent Table
    Short text            Compressed Data from FI/CO Document
    Last Change        SAP              10.02.2005
    Status                 Active           Saved
    Data class         APPL1   Transaction data, transparent tables
    Size category      4       Data records expected: 24,000 to 89,000
    Thanku

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

  • Problem with truncate table in procedure ora -00054

    hi do anybody know where is mistake ???
    the procedure has problem with truncate table
    ora - 00054: resource busy and acquire with NOWAIT specified
    ora - 06512 at "POVAPSYS.HMAN_P_REFRESH", line 6
    ora - 06512 at "POVAPSYS.POVAPSYS", line 6
    ora - 06512 at line 1
    this is my procedure....
    AS
    BEGIN
    execute immediate 'TRUNCATE TABLE hman_t_max';
    INSERT INTO hman_t_max SELECT * FROM hman_v_max;
    COMMIT;
    END;

    2.MAKE SURE THAT OTHER THAN YOU ANYBODY IS TRYING TO
    COMPILE AND RUN THE PROCEDUREShould he make sure that anybody is running the procedure?
    3.MAKE SURE THAT ANY PARALLEL QUERY IS RUNNING IN THE
    SERVER SIDE,THATS KEEPS THE RESOURCE BUSYShould he make sure any parallel query is running in the server side to keep the resource busy?
    Gita,
    I COULDN'T RESIST HAVING ONE SUGGESTION FOR YOU. Please look at the impact of your English in the reply before posting. Check if that sends reverse message!
    Cheers
    Sarma.

Maybe you are looking for