oracle—回收站

(1)目前oracle( Release 10.2.0.1.0)回收站不支持系统表空间
[1]实验
SQL> SELECT tablespace_name FROM USER_TABLES WHERE table_name='T';
TABLESPACE_NAME
------------------------------
SYSTEM

SQL> select count(*) from t;
  COUNT(*)
----------
     10000
SQL> drop table t;
Table dropped.
SQL> select count(*) from t;
select count(*) from t
                     *
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> rollback;
Rollback complete.
SQL> select count(*) from t;
select count(*) from t
                     *
ERROR at line 1:
ORA-00942: table or view does not exist (可见oracle的drop是自动提交的)

SQL> SELECT original_name, object_name, TYPE, droptime FROM user_recyclebin;
no rows selected

可见我们删除的t表没有放入回收站!
(2) 闪回表特性,可以毫不费力地恢复被意外删除的表
[1]实验
一 创建用户和授权
SQL> create user test identified by ss123456;
User created.
SQL> grant connect,create table ,resource  to test;
Grant succeeded.

C:/Documents and Settings/Administrator>sqlplus [email=test/ss123456@ot]test/ss123456@ot[/email]
SQL*Plus: Release 9.0.1.0.1 - Production on Thu May 14 15:00:26 2009
(c) Copyright 2001 Oracle Corporation.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
二 建demo表
SQL> create table demo (id int);
Table created.
SQL> insert into demo values (1);
1 row created.
SQL> commit;
Commit complete.
SQL> SELECT tablespace_name FROM USER_TABLES WHERE table_name='DEMO';
TABLESPACE_NAME
------------------------------
USERS

可见用户的表建在了users表空间中;
三 删除demo
SQL> drop table demo;
Table dropped.
SQL> commit;
Commit complete.
SQL> select * from demo;
select * from demo
              *
ERROR at line 1:
ORA-00942: table or view does not exist
四 利用闪回表特性,可以毫不费力地恢复被意外删除的表
1 查看回收站
SQL> SELECT original_name, object_name, TYPE, droptime FROM user_recyclebin;
ORIGINAL_NAME     OBJECT_NAME       TYPE                                   DROPTIME
-------------    ---------------------------          ------------                              -------------------
DEMO              BIN$cI/hTpOYT4GOLWfF+7O78Q==$0   TABLE        2009-05-14:15:09:40
2 恢复
SQL> FLASHBACK TABLE demo TO BEFORE DROP;
闪回完成。
SQL> select * from demo;
        ID
----------
         1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值