天天看点

清空数据库SQL

一、禁止所有的外键约束

SELECT 'ALTER TABLE ' || table_name || ' disable CONSTRAINT ' || constraint_name || ';' FROM user_constraints where CONSTRAINT_TYPE = 'R';

二、用delete或truncate删除所有表的内容

SELECT 'DELETE FROM '|| table_name || ';' FROM USER_TABLES ORDER BY TABLE_NAME;

三、把已经禁止的外键打开

SELECT 'ALTER TABLE ' || table_name || ' enable CONSTRAINT ' || constraint_name || ';' FROM user_constraints where CONSTRAINT_TYPE = 'R';

转载于:https://www.cnblogs.com/zhangliang1988/p/4994601.html