SQL: delete all the data from all available tables

前端 未结 9 1146
小蘑菇
小蘑菇 2020-12-09 08:43

I am using oracle DB to maintain more than 30 tables, how can I delete all the data from all the tables? I only want to delete the data but not drop the tables.

9条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 09:19

    The potential drawback with a truncate is that it may fail on referential integrity constraints. So you'd want to disable foreign key constraints first, then do the truncate, then re-enable constraints. The 'plus' with cloning the schema (exp and imp) is that you could also drop and recreate the tablespace too (which you may want to do if you want to reclaim some physical disk space as a result of removing all the data).

提交回复
热议问题