清空一个表里面所有数据

删除数据:
delete from student:删除所有数据,表结构还在,写日志,可以恢复,速度慢
drop table student:删除表的结构和数据
truncate table student:删除表中的所有记录,表结构还在。不写日志,无法恢复,但速度快
根据具体情况使用:千万要注意下面最后一个,因为无法恢复!
delete可以通过日志恢复
drop可以通过闪回恢复
1:drop的恢复方法
SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
DEPT                           TABLE   
EMP                            TABLE   
BONUS                          TABLE   
SALGRADE                       TABLE   
A                              TABLE   
B                              TABLE   

6 rows selected

SQL> drop table A;

Table dropped

SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
DEPT                           TABLE   
EMP                            TABLE   
BONUS                          TABLE   
SALGRADE                       TABLE   
BIN$+zs69B0+R3m1DnI8M0whxw==$0 TABLE  说明还没有真正删除 
B                              TABLE   

6 rows selected

SQL> show recyclebin;
SQL> flashback table A to before drop;恢复语句

Done

SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
DEPT                           TABLE   
EMP                            TABLE   
BONUS                          TABLE   
SALGRADE                       TABLE   
A                              TABLE   
B                              TABLE   

6 rows selected

2:delete的恢复方法
SQL> select * from A;

                                    NUM
---------------------------------------
                                      1
                                      3

SQL> savepoint a;

Savepoint created

SQL> delete  from A;

2 rows deleted

SQL> select * from A;

                                    NUM
---------------------------------------

SQL> rollback to a;

Rollback complete

SQL> select * from A;

                                    NUM
---------------------------------------
                                      1
                                      3

SQL>

posted @ 2018-11-27 21:12  动感小火鸡  阅读(1802)  评论(0编辑  收藏  举报