exp导出报错“ORA-00904: : invalid identifier ”的处理

今天在生产库上用exp导出一张临时表,环境是10.2.0.4.0 64bit AIX 6.1,遇到了以下错误:

About to export specified table via Conventional Path ...
.  . exporting table                       TMP_CLSLEVELDATA_WY_5
. exporting foreign function library names for user JFY 
. exporting PUBLIC type synonyms
EXP-00008: ORACLE error 904 encountered
ORA-00904: : invalid identifier
EXP-00000: Export terminated unsuccessfully

导出的与语句为:
exp abc/abc file=tmp.dmp log=tmp.log tables= TMP_CLSLEVELDATA_WY_5

按理说,命令已经是最小化参数设置了,没理由写错的,查找了半天文档,发现原来是因为导出用户没有dbms_java包的执行权限导致的

关于这个报错,MOS上的文档有说明:

Errors EXP-8 ORA-904 During Export (Doc ID 1091927.1)

In this Document

  Symptoms
  Cause
  Solution


Applies to:

Oracle Database - Enterprise Edition - Version 10.2.0.4 and later
Information in this document applies to any platform.
***Checked for relevance on 27-Jun-2013***

Symptoms

You are attempting to perform an export as the SYSTEM user or a DBA. During export, the following errors occurred:

EXP-00008: ORACLE error 904 encountered
ORA-00904: : invalid identifier


When performing a trace on the export, we see that the ORA-904 error is caused by the following statement:

PARSE ERROR #9:len=302 dep=0 uid=5 oct=3 lid=5 tim=778463694169 err=904
SELECT SYNNAM, DBMS_JAVA.LONGNAME(SYNNAM), DBMS_JAVA.LONGNAME(SYNTAB), TABOWN, TABNODE, PUBLIC$, SYNOWN, SYNOWNID, TABOWNID, SYNOBJNO FROM SYS.EXU9PTS WHERE SYNOBJNO IN ( SELECT SYNOBJNO FROM SYS.EXU9TYPT WHERE TABOBJNO = :1 ) ORDER BY SYNTIME

Cause

The PUBLIC privilege has been revoked from the DBMS_JAVA package.

Privileges to the DBMS_JAVA package are needed for the export to succeed. However, as there is concern about security issues due to privileges on the DBMS_JAVA many have revoked the execute privilege to this package to keep the database secure.

Solution

Explicitly grant EXECUTE on the DBMS_JAVA package to the DBA role:

SQL> grant execute on DBMS_JAVA to dba;


This will allow members of the DBA role to have the rights to perform the export while keeping the DBMS_JAVA package out of the PUBLIC role.


由于abc用户不是dba用户,因此采取workaround变通一下,临时授予abc用户dba权限,并将执行dbms_java包的权限赋予dba角色,然后再进行exp导出,就能够顺利完成了,最后出于数据库安全性方面的考虑,不要忘记将之前赋予的权限都取消掉

SQL> grant dba to abc;
SQL>  grant execute on DBMS_JAVA to dba;

exp abc/abc file=tmp.dmp log=tmp.log tables= TMP_CLSLEVELDATA_WY_5

SQL> revoke dba from abc;
SQL>  revoke execute on DBMS_JAVA from dba;

最后在目标库上将表用imp导入的时候要注意,由于之前是授予abc用户dba权限后导出的,因此在导入的时候,导入用户也必须拥有dba权限,否则仍然会报错,imp导入完成后,再取消导入用户的dba权限即可。


你可能感兴趣的:(oralce,exp,imp,ORA-00904,DBMS_JAVA)