先转一篇
================================我是分割线================================
时间:2013-06-22 13:48来源:未知 作者:admin 点击:次
$ exp username/password file=expdat.dmp tables=tablename 这是一条经历了磨难的语句,然而最终也还是修成正果 最开始报错: EXP-00008: ORACLE error 904 encountered ORA-00904: DBMS_JAVA.LONGNAME: invalid identifier Export terminated successfully
$ exp username/password file=expdat.dmp tables=tablename
这是一条经历了磨难的语句,然而最终也还是修成正果 :)
最开始报错:
EXP-00008: ORACLE error 904 encountered
ORA-00904: “DBMS_JAVA”.”LONGNAME”: invalid identifier
Export terminated successfully with warnings.
重新运行了$ORACLE_HOME/rdbms/admin/catexp.sql,无效,错误依旧。
*具体运行方法
[oracle@10 ~]$ sqlplus / as sysdba
连上db之后在里面通过执行sql邮件来使之生效
SQL>@/home/oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catexp.sql
(下同,略)
然后运行$ORACLE_HOME/javavm/install/initdbj.sql,重新创建dbms_java包,这个错误消失了。
我这边遇到的情况验证到这一步就解决了。
再次运行exp,报错:
Export done in US7ASCII character set and UTF8 NCHAR character set
server uses UTF8 character set (possible charset conversion)
EXP-00008: ORACLE error 6552 encountered
ORA-06552: PL/SQL: Compilation unit analysis terminated
ORA-06553: PLS-553: character set name is not recognized
Export terminated successfully with warnings.
检查系统环境,发现在props$中字符集是UTF8,但是操作系统环境变量没有设置NLS_LANG,于是:
NLS_LANG=AMERICAN_AMERICA.UTF8;export NLS_LANG
再次运行exp,仍然报错:
Export done in UTF8 character set and UTF8 NCHAR character set
EXP-00008: ORACLE error 6552 encountered
ORA-06552: PL/SQL: Compilation unit analysis terminated
ORA-06553: PLS-553: character set name is not recognized
Export terminated successfully with warnings.
于是询问客户是否有做过字符集的修改,果然,在很久很久以前,他们手动update props$表修改了字符集(手动修改props$是oracle7的招数,在oracle8和oracle9中虽然也能修改,但是会留下修改不干净的隐患)
首先,确认字符集是否修改的不彻底。
SELECT DISTINCT (NLS_CHARSET_NAME(CHARSETID)) CHARACTERSET,
DECODE(TYPE#,
1,
DECODE(CHARSETFORM,
1,
'VARCHAR2',
2,
'NVARCHAR2',
'UNKOWN'),
9,
DECODE(CHARSETFORM,
1,
'VARCHAR',
2,
'NCHAR VARYING',
'UNKOWN'),
96,
DECODE(CHARSETFORM, 1, 'CHAR', 2, 'NCHAR', 'UNKOWN'),
112,
DECODE(CHARSETFORM, 1, 'CLOB', 2, 'NCLOB', 'UNKOWN')) TYPES_USED_IN
FROM SYS.COL$
WHERE CHARSETFORM IN (1, 2)
AND TYPE# IN (1, 9, 96, 112);
CHARACTERSET TYPES_USED_IN
-------------------- -------------
AL16UTF16 NCHAR
AL16UTF16 NCLOB
AL16UTF16 NVARCHAR2
UTF8 CHAR
UTF8 VARCHAR2
WE8ISO8859P1 CHAR
WE8ISO8859P1 CLOB
WE8ISO8859P1 VARCHAR2
8 rows selected.
确实在数据库的列属性中仍然存在着多个字符集的设定,这是导致exp失败的原因。下面解决这个问题。
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER SYSTEM ENABLE RESTRICTED SESSION;
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
ALTER SYSTEM SET AQ_TM_PROCESSES=0;
ALTER DATABASE OPEN;
COL VALUE NEW_VALUE CHARSET
SELECT VALUE FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER='NLS_CHARACTERSET';
COL VALUE NEW_VALUE NCHARSET
SELECT VALUE FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER='NLS_NCHAR_CHARACTERSET';
--INTERNAL_USE是没有写在文档中的参数,用以强制完成字符集一致化
ALTER DATABASE CHARACTER SET INTERNAL_USE &CHARSET;
ALTER DATABASE NATIONAL CHARACTER SET INTERNAL_USE &NCHARSET;
SHUTDOWN IMMEDIATE;
STARTUP;
-- 再次启动数据库一遍
SHUTDOWN IMMEDIATE;
STARTUP;
按照上面的步骤,一步一步来,一步不要少,完成以后,重新检索col$表。
CHARACTERSET TYPES_USED_IN
-------------------- -------------
UTF8 CHAR
UTF8 CLOB
UTF8 NCHAR
UTF8 NCLOB
UTF8 NVARCHAR2
UTF8 VARCHAR2
干净了,再次运行exp,大功告成。
Export terminated successfully without warnings.
(责任编辑:admin)
================================我是分割线================================
然后有个问题不晓得是不是不正常,我这边在命令行里面直接写
exp usernam/pwd@dbname file=file.dmp
或exp usernam/pwd@dbname
的时候会出错。
Export: Release 11.2.0.1.0 - Production on Fri Sep 26 11:05:43 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
EXP-00056: ORACLE error 12154 encountered
ORA-12154: TNS:could not resolve the connect identifier specified
EXP-00000: Export terminated unsuccessfully
于是我尝试写了exp,就可以正常进行了。然后出现的一系列内容的填写。
[oracle@10 ~]$ exp
Export: Release 11.2.0.1.0 - Production on Fri Sep 26 11:16:30 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Username: opr001
Password:
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Enter array fetch buffer size: 4096 >【回车】------选择默认的情况下,直接回车就行了,下同
Export file: expdat.dmp > test0926.dmp
(1)E(ntire database), (2)U(sers), or (3)T(ables): (2)U > 2 *这里我随便选了2,自己按需选择顺序或者写缩写(E,U,T)
Export grants (yes/no): yes >【回车】------默认是yes
Export table data (yes/no): yes >【回车】------默认是yes
Compress extents (yes/no): yes >【回车】------默认是yes
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses JA16SJIS character set (possible charset conversion)
About to export specified users ...
User to be exported: (RETURN to quit) > .. *这里一般默认写上两个点【..】
Export terminated successfully without warnings.
完了导出成功,在oracle_home下找到刚才的dmp文件。
*oracle_home为自定义环境变量或者叫安装目录吧,同windows系统下面的概念。
我这边的oracle_home为:/home/oracle/app/oracle/product/11.2.0/