shark 发表于 2010-12-3 21:25:25

truncate ,delete ,drop的区别

1.truncate和delete删除表中的数据;drop是将表从数据字典中删除,并清空表中的数据。
2.truncate和drop 为DDL语句,不会产生重做日志;delete为DML语句,会产生重做日志。
3.truncate之后会降低高水位线,而delete之后不会降低高水位线。
4.truncate,drop,delete执行所花的时间不同。
SQL> set timing on
SQL> delete from test;
151358 rows deleted.
Elapsed: 00:00:06.16
SQL> rollback;
Rollback complete.
Elapsed: 00:00:07.00
SQL> drop table test;
Table dropped.
Elapsed: 00:00:00.36
SQL> flashback table test to before drop;
Flashback complete.
Elapsed: 00:00:00.02
SQL> drop table test purge;
Table dropped.
Elapsed: 00:00:00.06
SQL> truncate table test;
Table truncated.
Elapsed: 00:00:00.34

页: [1]
查看完整版本: truncate ,delete ,drop的区别