/* before_trunc.sql
This script gives disble constrints script before truncating table
*/
accept tblname prompt ‘Enter the Table Name You want to truncate -> ‘
column head heading “Execute Following Statements To Truncate &tblname, as &tblname is referenced by following foreign keys”
select ‘alter table ‘ || lpad(b.table_name, 30) || ‘ disable constraint ‘ || b.constraint_name || ‘;’ as “Head”
from user_constraints a, user_constraints b
where a.constraint_name = b.r_constraint_name
and a.table_name = upper(‘&tblname’);