oracle10g的undrop功能一點實踐
看到oracle10g有防止表誤刪除的特點,我自己就小試了一把,
下面是我的操作過程:
bash-2.05$ sqlplus scott/tiger
SQL*Plus: Release 10.1.0.0.0 - Beta on Mon Aug 18 16:50:18 2003
Copyright (c) 1982, 2003, Oracle Corporation. All rights reserved.
Connected to:
Oracle10i Enterprise Edition Release 10.1.0.0.0 - Beta
With the Partitioning and Oracle Data Mining options
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------
BONUS TABLE
DUMMY TABLE
EMP TABLE
EMP2 TABLE
SALGRADE TABLE
T TABLE
6 rows selected.
SQL> desc emp2;
Name Null? Type
------------------------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
SQL> select * from emp2; so.2168.net網管資料庫任你搜
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- -----
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
SQL> drop table emp2;
Table dropped.
SQL> select * from emp2;
select * from emp2
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
-----------------------------
BONUS TABLE
DUMMY TABLE
EMP TABLE
RB$$8074$TABLE$0 TABLE(oracle在recycle bin裡面生成的物件,就是emp2的複製)
SALGRADE TABLE
T TABLE
6 rows selected.
SQL> desc RB$$8074$TABLE$0;
Name Null? Type
---------------------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2) 需要什麼來搜一搜吧so.2168.net
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
SQL> select * from RB$$8074$TABLE$0;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ----------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
SQL> undrop table RB$$8074$TABLE$0;(應該是把表從Recycle Bin中去掉)
Table undropped.
SQL> alter table RB$$8074$TABLE$0 rename to emp2;
Table altered.
SQL> select * from emp2;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- ------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
可以看到所有的資料都在,對錶可以執行DDL,DML操作
SQL> insert into emp2 select * from emp;
14 rows created.
如果不執行“undrop table RB$$8074$TABLE$0”而直接執行“alter table RB$$8074$TABLE$0 rename to emp2”
就會有如下問題:
SQL> insert into emp2 select * from emp;
insert into emp2 select * from emp
*
ERROR at line 1:
ORA-38301: can not perform DDL/DML over objects in Recycle Bin
如果要刪除Recycle Bin中表可以:
SQL> purge table RB$$8063$TABLE$0;
Table purged.
這樣這個表就真的刪除了,也就可能再undrop了!
下面是我的操作過程:
bash-2.05$ sqlplus scott/tiger
SQL*Plus: Release 10.1.0.0.0 - Beta on Mon Aug 18 16:50:18 2003
Copyright (c) 1982, 2003, Oracle Corporation. All rights reserved.
Connected to:
Oracle10i Enterprise Edition Release 10.1.0.0.0 - Beta
With the Partitioning and Oracle Data Mining options
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------
BONUS TABLE
DUMMY TABLE
EMP TABLE
EMP2 TABLE
SALGRADE TABLE
T TABLE
6 rows selected.
SQL> desc emp2;
Name Null? Type
------------------------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
SQL> select * from emp2; so.2168.net網管資料庫任你搜
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- -----
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
SQL> drop table emp2;
Table dropped.
SQL> select * from emp2;
select * from emp2
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
-----------------------------
BONUS TABLE
DUMMY TABLE
EMP TABLE
RB$$8074$TABLE$0 TABLE(oracle在recycle bin裡面生成的物件,就是emp2的複製)
SALGRADE TABLE
T TABLE
6 rows selected.
SQL> desc RB$$8074$TABLE$0;
Name Null? Type
---------------------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2) 需要什麼來搜一搜吧so.2168.net
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
SQL> select * from RB$$8074$TABLE$0;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ----------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
SQL> undrop table RB$$8074$TABLE$0;(應該是把表從Recycle Bin中去掉)
Table undropped.
SQL> alter table RB$$8074$TABLE$0 rename to emp2;
Table altered.
SQL> select * from emp2;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- ------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
可以看到所有的資料都在,對錶可以執行DDL,DML操作
SQL> insert into emp2 select * from emp;
14 rows created.
如果不執行“undrop table RB$$8074$TABLE$0”而直接執行“alter table RB$$8074$TABLE$0 rename to emp2”
就會有如下問題:
SQL> insert into emp2 select * from emp;
insert into emp2 select * from emp
*
ERROR at line 1:
ORA-38301: can not perform DDL/DML over objects in Recycle Bin
如果要刪除Recycle Bin中表可以:
SQL> purge table RB$$8063$TABLE$0;
Table purged.
這樣這個表就真的刪除了,也就可能再undrop了!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/35489/viewspace-84746/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 一點點最佳實踐
- Node+Express的一點實踐Express
- 基於 GraphQL 實踐的一點思考
- 快速實現oracle10g的審計功能Oracle
- MySQL InnoDB效能調整的一點實踐MySql
- 原生JS實現你畫我猜的一點點功能JS
- Redis在秒殺功能的實踐Redis
- 關於Python一等函式的一點實踐Python函式
- 【Flashback】Flashback Query功能實踐
- 【Flashback】Flashback Table功能實踐
- vue移動助手實踐(一)——基於vue的換膚功能Vue
- 【實驗】【Flashback】Flashback EXP功能實踐
- Oracle10g Data Guard (Standby) 理論與實踐Oracle
- MySQL中使用undrop來恢復drop的表(上)MySql
- 【實踐篇】基於CAS的單點登入實踐之路
- 站點登入功能的實現
- 自定義限速功能實踐——Caffeine
- 【實驗】【Flashback】Flash Version Query功能實踐
- 【實驗】【Flashback】Flashback Transaction Query功能實踐
- 用Flutter實現一個精美的點單功能Flutter
- 讓寫作省心一點——Markdown和CSS實踐CSS
- Decorator:從原理到實踐,我一點都不虛~
- Oracle10g RAC或者ASM的一個注意點,再重點強調一下OracleASM
- Oracle10g Data Guard (Standby) 理論與實踐 2Oracle
- oracle10g 審計功能Oracle
- 直播轉點播實踐
- 同步秒殺實現:Redis在秒殺功能的實踐Redis
- SOA 非功能測試最佳實踐
- 自定義限速功能實踐——Map 版本
- 織夢點選圖片實現下一頁功能
- go的協程及channel與web開發的一點小實踐GoWeb
- 下一代軟體工程的思考與點滴實踐軟體工程
- 【實踐思考】自己開發一個掘金黑名單功能外掛
- Oracle10g Data Guard (Standby) 理論與實踐 [final]Oracle
- Oracle10g新功能介紹Oracle
- vue專案實踐004~~~一籃子的實踐技巧Vue
- Oracle10g增加線上加密過程的功能Oracle加密
- Redis實現點贊功能模組Redis