TRUNCATE TABLE
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: TRUNCATE TABLE

  1. #1
    Join Date
    Sep 2000
    Posts
    77
    I have a table with 500,000 rows. I need to cleanup this table every quarter and i have load fresh data approx 400,000 rows. I am planning to use Dynamic sql inside a stored procedure like
    EXECUTE IMMEDIATE 'TRUNCATE TABLE table_name' ;
    Can someone please suggest me is this a good idea or i need to build a cursor and delete rows.
    Thanks

  2. #2
    I guess you are right.
    Or you can use DBMS_SQL (for old versions)
    If you want to maintain history you can use partitions.
    Ramon Caballero, DBA, rcaballe@yahoo.com

  3. #3
    Join Date
    Apr 2001
    Posts
    47
    Hi CHALAVADI,

    You do not need to create a cursor or use dynamic SQL to truncate the table. If you are the owner of the table, you can use just ‘TRUNCATE TABLE ’ syntax.
    Or if you truncate the table every time before you load data into it using SQLLoader, you can just add TRUNCATE keyword in the SQLLoader control file. In this case SQLLoader would truncate the table for you just before it loads data.

    Hope it helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width