Oracle之處理synonym同義詞無效物件
Oracle之處理synonym同義詞無效物件
ORA-00980: synonym translation is no longer valid
1. 舉例,在sys使用者下建一個t表
[oracle@testdb1 ~]:testdb1> sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.4.0 Production on Fri Nov 14 09:33:29 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table t (x number);
Table created.
SQL> insert into t values (1);
1 row created.
SQL> commit;
Commit complete.
2. 再建立一個sec使用者
SQL> create user sec identified by sec;
User created.
3. 使用sec使用者,建立同名表syn_t
SQL> conn sec/sec
ERROR:
ORA-01045: user SEC lacks CREATE SESSION privilege; logon denied
Warning: You are no longer connected to ORACLE.
SQL> grant dba to sec;
SP2-0640: Not connected
SQL> conn /as sysdba;
Connected.
SQL> grant dba to sec;
Grant succeeded.
SQL> conn sec/sec
Connected.
SQL> create synonym syn_t for sys.t;
Synonym created.
SQL> select * from syn_t;
X
----------
1
4. 刪除sys使用者下的t表
SQL> conn /as sysdba
Connected.
SQL> drop table t purge;
Table dropped.
SQL> conn sec/sec
SQL> conn sec/sec
Connected.
+++++++++++++++++++++++++++++++++++++++++++++++++++++
SQL> select * from syn_t;
select * from syn_t
*
ERROR at line 1:
ORA-00980: synonym translation is no longer valid
SQL>
+++++++++++++++++++++++++++++++++++++++++++++++++++++
#產生了無效同名
導致“ORA-00980”錯誤的原因:
1.刪除了資料庫物件,但是忘記刪除同名;
2.刪除一個使用者,但是忘記刪除與此使用者中相關的同名;
3.建立同名時,同名對應的資料庫物件已經被刪除掉了
表t刪除,但是同名還可以建立
SQL> show user;
USER is "SEC"
SQL> create synonym syn_public_t for sys.t;
Synonym created.
SQL> create synonym syn_tt for sys.t;
Synonym created.
報錯:
SQL> desc syn_tt;
ERROR:
ORA-04043: object "SYS"."T" does not exist
查詢無效物件:
SQL> set linesize 1000
SQL> SELECT OBJECT_NAME, OBJECT_TYPE, OWNER, CREATED, LAST_DDL_TIME, TIMESTAMP FROM dba_objects WHERE status = 'INVALID';
OBJECT_NAME OBJECT_TYPE OWNER CREATED LAST_DDL_TIME
-------------------------------------------------------------- ------------------- ------------------------------ ------------------- ------------------- -------------------
/53ad31cb_TagsLocator JAVA CLASS EXFSYS 2014-10-22 14:10:56 2014-11-12 14:40:46 2014-10-22:14:10:56
/357abd97_XPathFilter JAVA CLASS EXFSYS 2014-10-22 14:10:56 2014-11-12 14:40:46 2014-10-22:14:10:56
SYN_T SYNONYM SYS 2014-11-14 09:40:47 2014-11-14 09:40:47 2014-11-14:09:40:47
SQL>
處理辦法:
先採用方法一,再採用方法二。
方法一:
ALTER SYNONYM SYN_T compile;
SQL> ALTER SYNONYM SYN_T compile;
Synonym altered.
SQL> SELECT OBJECT_NAME, OBJECT_TYPE, OWNER, CREATED, LAST_DDL_TIME, TIMESTAMP FROM dba_objects WHERE status = 'INVALID';
OBJECT_NAME OBJECT_TYPE OWNER CREATED LAST_DDL_TIME TIMESTAMP
----------------------------------------------- ------------------- ------------------------------ ------------------- ------------------- -------------------
/53ad31cb_TagsLocator JAVA CLASS EXFSYS 2014-10-22 14:10:56 2014-11-12 14:40:46 2014-10-22:14:10:56
/357abd97_XPathFilter JAVA CLASS EXFSYS 2014-10-22 14:10:56 2014-11-12 14:40:46 2014-10-22:14:10:56
SYN_T SYNONYM SYS 2014-11-14 09:40:47 2014-11-14 09:40:47 2014-11-14:09:40:47
SQL> SELECT COUNT(*) FROM dba_objects WHERE status = 'INVALID' AND object_name NOT LIKE 'BIN$%' AND object_type NOT IN ('MATERIALIZED VIEW');
COUNT(*)
----------
3
不能清理。
方法二:直接刪除
查詢指令碼:
select 'drop '
|| decode (s.owner,
'PUBLIC', 'public synonym ',
'synonym ' || s.owner || '.')
|| s.synonym_name
|| ';' as "Dropping invalid synonyms:"
from dba_synonyms s
where table_owner not in ('SYSTEM', 'SYS') and db_link is null
and not exists
(select null
from dba_objects o
where s.table_owner = o.owner
and s.table_name = o.object_name)
/
SQL> select 'drop '
2 || decode (s.owner,
3 'PUBLIC', 'public synonym ',
4 'synonym ' || s.owner || '.')
5 || s.synonym_name
6 || ';' as "Dropping invalid synonyms:"
7 from dba_synonyms s
8 where table_owner not in ('SYSTEM') and db_link is null
9 and not exists
10 (select null
11 from dba_objects o
12 where s.table_owner = o.owner
13 and s.table_name = o.object_name)
14 /
Dropping invalid synonyms:
---------------------------------------------------------------------------
drop synonym SYS.SYN_T;
drop synonym SEC.SYN_PUBLIC_T;
drop synonym SEC.SYN_TT;
SQL> drop synonym SEC.SYN_TT;
SQL> drop synonym SEC.SYN_PUBLIC_T;
SQL> drop synonym SYS.SYN_T;
ORA-00980: synonym translation is no longer valid
1. 舉例,在sys使用者下建一個t表
[oracle@testdb1 ~]:testdb1> sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.4.0 Production on Fri Nov 14 09:33:29 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table t (x number);
Table created.
SQL> insert into t values (1);
1 row created.
SQL> commit;
Commit complete.
2. 再建立一個sec使用者
SQL> create user sec identified by sec;
User created.
3. 使用sec使用者,建立同名表syn_t
SQL> conn sec/sec
ERROR:
ORA-01045: user SEC lacks CREATE SESSION privilege; logon denied
Warning: You are no longer connected to ORACLE.
SQL> grant dba to sec;
SP2-0640: Not connected
SQL> conn /as sysdba;
Connected.
SQL> grant dba to sec;
Grant succeeded.
SQL> conn sec/sec
Connected.
SQL> create synonym syn_t for sys.t;
Synonym created.
SQL> select * from syn_t;
X
----------
1
4. 刪除sys使用者下的t表
SQL> conn /as sysdba
Connected.
SQL> drop table t purge;
Table dropped.
SQL> conn sec/sec
SQL> conn sec/sec
Connected.
+++++++++++++++++++++++++++++++++++++++++++++++++++++
SQL> select * from syn_t;
select * from syn_t
*
ERROR at line 1:
ORA-00980: synonym translation is no longer valid
SQL>
+++++++++++++++++++++++++++++++++++++++++++++++++++++
#產生了無效同名
導致“ORA-00980”錯誤的原因:
1.刪除了資料庫物件,但是忘記刪除同名;
2.刪除一個使用者,但是忘記刪除與此使用者中相關的同名;
3.建立同名時,同名對應的資料庫物件已經被刪除掉了
表t刪除,但是同名還可以建立
SQL> show user;
USER is "SEC"
SQL> create synonym syn_public_t for sys.t;
Synonym created.
SQL> create synonym syn_tt for sys.t;
Synonym created.
報錯:
SQL> desc syn_tt;
ERROR:
ORA-04043: object "SYS"."T" does not exist
查詢無效物件:
SQL> set linesize 1000
SQL> SELECT OBJECT_NAME, OBJECT_TYPE, OWNER, CREATED, LAST_DDL_TIME, TIMESTAMP FROM dba_objects WHERE status = 'INVALID';
OBJECT_NAME OBJECT_TYPE OWNER CREATED LAST_DDL_TIME
-------------------------------------------------------------- ------------------- ------------------------------ ------------------- ------------------- -------------------
/53ad31cb_TagsLocator JAVA CLASS EXFSYS 2014-10-22 14:10:56 2014-11-12 14:40:46 2014-10-22:14:10:56
/357abd97_XPathFilter JAVA CLASS EXFSYS 2014-10-22 14:10:56 2014-11-12 14:40:46 2014-10-22:14:10:56
SYN_T SYNONYM SYS 2014-11-14 09:40:47 2014-11-14 09:40:47 2014-11-14:09:40:47
SQL>
處理辦法:
先採用方法一,再採用方法二。
方法一:
ALTER SYNONYM SYN_T compile;
SQL> ALTER SYNONYM SYN_T compile;
Synonym altered.
SQL> SELECT OBJECT_NAME, OBJECT_TYPE, OWNER, CREATED, LAST_DDL_TIME, TIMESTAMP FROM dba_objects WHERE status = 'INVALID';
OBJECT_NAME OBJECT_TYPE OWNER CREATED LAST_DDL_TIME TIMESTAMP
----------------------------------------------- ------------------- ------------------------------ ------------------- ------------------- -------------------
/53ad31cb_TagsLocator JAVA CLASS EXFSYS 2014-10-22 14:10:56 2014-11-12 14:40:46 2014-10-22:14:10:56
/357abd97_XPathFilter JAVA CLASS EXFSYS 2014-10-22 14:10:56 2014-11-12 14:40:46 2014-10-22:14:10:56
SYN_T SYNONYM SYS 2014-11-14 09:40:47 2014-11-14 09:40:47 2014-11-14:09:40:47
SQL> SELECT COUNT(*) FROM dba_objects WHERE status = 'INVALID' AND object_name NOT LIKE 'BIN$%' AND object_type NOT IN ('MATERIALIZED VIEW');
COUNT(*)
----------
3
不能清理。
方法二:直接刪除
查詢指令碼:
select 'drop '
|| decode (s.owner,
'PUBLIC', 'public synonym ',
'synonym ' || s.owner || '.')
|| s.synonym_name
|| ';' as "Dropping invalid synonyms:"
from dba_synonyms s
where table_owner not in ('SYSTEM', 'SYS') and db_link is null
and not exists
(select null
from dba_objects o
where s.table_owner = o.owner
and s.table_name = o.object_name)
/
SQL> select 'drop '
2 || decode (s.owner,
3 'PUBLIC', 'public synonym ',
4 'synonym ' || s.owner || '.')
5 || s.synonym_name
6 || ';' as "Dropping invalid synonyms:"
7 from dba_synonyms s
8 where table_owner not in ('SYSTEM') and db_link is null
9 and not exists
10 (select null
11 from dba_objects o
12 where s.table_owner = o.owner
13 and s.table_name = o.object_name)
14 /
Dropping invalid synonyms:
---------------------------------------------------------------------------
drop synonym SYS.SYN_T;
drop synonym SEC.SYN_PUBLIC_T;
drop synonym SEC.SYN_TT;
SQL> drop synonym SEC.SYN_TT;
SQL> drop synonym SEC.SYN_PUBLIC_T;
SQL> drop synonym SYS.SYN_T;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29500582/viewspace-1332715/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 匯出oracle公有同義詞Oracle
- 6.5. 常用物件——6.5.4. 同義詞物件
- oracle學習筆記(十四) 資料庫物件 索引 檢視 序列 同義詞Oracle筆記資料庫物件索引
- 自定義事件相容處理物件事件物件
- 自然語言處理之jieba分詞自然語言處理Jieba分詞
- 如何處理快取導致的無效曝光快取
- 中考常見同義詞和同義短語總結
- [20191122]schama建立同義詞.txt
- 詞!自然語言處理之詞全解和Python實戰!自然語言處理Python
- 同花色同值牌處理
- ORACLE無法OPEN,處理三板斧Oracle
- 2.1.3 Python物件導向之異常處理Python物件
- Oracle SQL處理OracleSQL
- 自動為新建的表建立同義詞
- 同義詞相似度可以怎樣計算
- 【學習】SQL基礎-017-同義詞SQL
- oracle異常處理Oracle
- Oracle壞塊處理Oracle
- Python文字處理NLP:分詞與詞雲圖Python分詞
- Oracle日常問題處理-資料庫無法啟動Oracle資料庫
- Elasticsearch:使用同義詞 synonyms 來提高搜尋效率Elasticsearch
- oralce 跨使用者訪問表 同義詞
- Foobar2000之處理無損音樂格式
- 處理文字資料(上):詞袋
- 自然語言處理:分詞方法自然語言處理分詞
- Oracle ORA-06575: 程式包或函式WM_CONCAT處於無效狀態Oracle函式
- oracle高水位線處理Oracle
- oracle ORA-08104處理Oracle
- oracle 高水位分析處理Oracle
- Oracle更新Opatch故障處理Oracle
- Oracle非法日期 處理方案Oracle
- Oracle TX鎖的處理Oracle
- Oracle 無備份情況下undo檔案損壞處理Oracle
- ORACLE RAC 11.2.0.4 FOR RHEL6叢集無法啟動的處理Oracle
- SpringBoot 配置CORS處理前後端分離跨域配置無效問題解析Spring BootCORS後端跨域
- win10ie主頁修改了無效怎麼回事 win10修改ie瀏覽器主頁無效怎麼處理Win10瀏覽器
- 祂無處不在 -- 疾病的處理.
- 【Oracle】sys下缺失和無效物件導致exp、expdp和RMAN等備份功能全部報錯Oracle物件
- Oracle 監聽異常處理Oracle