How to delete all data from tables in PL/SQL?

In PL/SQL, you can use the following statement to delete all table data:

BEGIN
   FOR cur_rec IN (SELECT table_name FROM user_tables) LOOP
      EXECUTE IMMEDIATE 'DELETE FROM ' || cur_rec.table_name;
   END LOOP;
END;
/

This code will iterate through all the tables owned by a user and execute a DELETE statement on each table to delete all the data. Please be cautious before running this code, as it will permanently delete all the data in the tables.

bannerAds