Monday, October 31, 2011

Script to Truncate multiple tables using PL/SQL block


Below is the script to truncate multiple tables in single go. Put the table names to be truncated in the 'IN' condition/

BEGIN

 FOR i IN (SELECT table_name FROM user_tables WHERE table_name IN ('TABLE1','TABLE2','---' ))

 LOOP

      EXECUTE IMMEDIATE 'TRUNCATE TABLE ' || i.table_name;

  END LOOP;

END;

No comments:

Post a Comment