联系:手机/微信(+86 17813235971) QQ(107644445)
标题:误删除dual表恢复
作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]
1.10G中删除dual表恢复
SQL> select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod PL/SQL Release 10.2.0.1.0 - Production CORE 10.2.0.1.0 Production TNS for Linux: Version 10.2.0.1.0 - Production NLSRTL Version 10.2.0.1.0 - Production SQL> select object_type,owner from dba_objects where object_name='DUAL'; OBJECT_TYPE OWNER ------------------- ------------------------------ TABLE SYS SYNONYM PUBLIC SQL> drop table sys.dual; Table dropped. SQL> select object_type from dba_objects where object_name='DUAL'; OBJECT_TYPE ------------------- SYNONYM SQL> SELECT SYSDATE FROM dual; SELECT SYSDATE FROM dual * ERROR at line 1: ORA-01775: looping chain of synonyms SQL> CREATE TABLE XFF AS SELECT * from dba_objects; Table created. SQL> drop table xff purge; drop table xff purge * ERROR at line 1: ORA-00604: error occurred at recursive SQL level 1 ORA-01775: looping chain of synonyms 设置10046跟踪会话发现,在每次删除表操作的时候发现如下错误 select dummy from dual where ora_dict_obj_type = 'TABLE'
其实这里错误都很明显,是因为dual表不存在了,表对应的同义词还存在,当查询dual的时候,会去查询同义词,然后该同义词去找表,而表不存在,所以出现上述的ORA-01775: looping chain of synonyms错误
2.解决方法
SQL> CREATE TABLE "SYS"."DUAL" 2 ( "DUMMY" VARCHAR2(1) 3 ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING 4 STORAGE(INITIAL 16384 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 5 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) 6 TABLESPACE "SYSTEM" ; Table created. SQL> GRANT SELECT ON "SYS"."DUAL" TO PUBLIC WITH GRANT OPTION; Grant succeeded. SQL> insert into dual values('X'); 1 row created. SQL> COMMIT; Commit complete. --编译对象 SQL> @?/rdbms/admin/utlrp.sql
3.测试结果
SQL> select sysdate from dual; SYSDATE ------------ 13-MAR-12 SQL> drop table xff purge; Table dropped.
11G中删除dual表恢复
删除dual重启数据库后恢复
1.模拟删除dual表重启数据库
2.查看alert文件
3.查看trace文件
从这里可以看出,数据库在启动的时候,因为无dual表导致死锁,然后启动失败
4.设置replication_dependency_tracking解决问题