日期:2014-05-16  浏览次数:20418 次

Oracle中的dual表恢复

本文内容来至

http://www.itpub.net/viewthread.php?tid=981212&extra=&page=1

?

如果dual表不在了,也可以用下面的方法恢复:(借此做个记录)
可以通过执行以下步骤来进行恢复。可以用sys用户登陆。
SQL> create pfile='dualfile.bak' from spfile
SQL> shutdown immediate
在dualfile.bak文件中最后加入一条:replication_dependency_tracking = FALSE
重新启动数据库:
SQL> startup pfile='dualfile.bak'
SQL> create table "sys"."DUAL"
? ???( "DUMMY" varchar2(1) )
? ???pctfree 10 pctused 4;
SQL> insert into dual values('X');
SQL> commit;
SQL> Grant select on dual to Public;
授权成功。

SQL> select * from dual;

D
-
X

SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup
ORACLE 例程已经启动。

---------------------------------------------------

?

?

dual表给弄坏了,drop操作看来是要用到dual表的,解决的步骤如下(主要是把dual表修复了一下):

1.先创建了一个自定义的dual表暂时顶替
sys@TEST>create table my_dual as select dummy from dual;

Table created.

sys@TEST>select * from my_dual;

D
-
X

2.创建临时dual表的同义词,并赋给所有用户select的权限
sys@TEST>create public synonym dual for my_dual;

Synonym created.

sys@TEST>grant select on my_dual to public;

Grant succeeded.

3.删除dual表
sys@TEST>drop table sys.dual;

Table dropped.

4.重建dual表
sys@TEST>create table dual as select * from dual;

Table created.

5.删除在临时dual表上建立的同义词
sys@TEST>drop public synonym??dual;

Synonym dropped.

sys@TEST>select * from dual;

D
-
X

6.创建dual表的同义词,并赋给所有用户select的权限
sys@TEST>create public synonym dual for sys.dual;

Synonym created.

sys@TEST>grant select on dual to public;

Grant succeeded.

删除表空间没有问题了
sys@TEST>drop tablespace temp01 including contents and datafiles;

Tablespace dropped.

看样在dual表在Oracle数据库中还是很重要的