expdp无法导出中文表名数据的解决方法

expdp无法导出中文表名数据的解决方法

𝓓𝓸𝓷 Lv6

一、导出中文表名查无此表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[oracle@xmdb ~]$ schemas=hie
[oracle@xmdb ~]$ directory=expdir
[oracle@xmdb ~]$ date_d=`date +%Y-%m-%d`
[oracle@xmdb ~]$ expdp \"/ as sysdba\" directory=$directory tables=\"hie.学生成绩表\" dumpfile=xscjb_${date_d}.dmp logfile=expdp_xscjb_${date_d}.log exclude=statistics
Export: Release 11.2.0.4.0 - Production on Fri Nov 13 10:26:06 2026

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_TABLE_01": "/******** AS SYSDBA" directory=expdir tables="hie.学生成绩表" dumpfile=学生成绩表_2026-11-13.dmp logfile=expdp_学生成绩表_2026-11-13.log exclude=statistics
Estimate in progress using BLOCKS method...
Total estimation using BLOCKS method: 0 KB
ORA-39166: Object HIE.学生成绩表 was not found.
ORA-31655: no data or metadata objects selected for job
Job "SYS"."SYS_EXPORT_TABLE_01" completed with 2 error(s) at Fri Nov 13 10:26:10 2026 elapsed 0 00:00:03

二、检查字符集

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[oracle@xmdb ~]$ echo $NLS_LANG
AMERICAN_AMERICA.ZHS16GBK
[oracle@xmdb ~]$ echo $LANG
zh_CN.UTF-8
[oracle@xmdb ~]$ locale charmap
UTF-8
[oracle@xmdb ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Nov 13 10:28:20 2026

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, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> SELECT value FROM nls_database_parameters WHERE parameter='NLS_CHARACTERSET';

VALUE
--------------------------------------------------------------------------------
ZHS16GBK

三、原因分析

终端输入编码(UTF-8)与 Oracle 客户端声明的字符集(ZHS16GBK)不匹配。

  • $LANG 和 locale charmap 显示你的 Linux 终端实际使用 UTF-8 编码输入中文。
  • NLS_LANG 却设置为 AMERICAN_AMERICA.ZHS16GBK,告诉 Oracle 客户端”我传给你的是 GBK 编码”。
  • 当你在 UTF-8 终端中输入中文表名时,Shell 以 UTF-8 字节流传递给 expdp,但 expdp 按 NLS_LANG 指示将其当作 GBK 解读并转码发送给数据库,导致字节序列错乱,Oracle 服务端无法匹配到真实表名。

四、解决方法

在命令行添加字符集export NLS_LANG=AMERICAN_AMERICA.AL32UTF8再导出

将 NLS_LANG 改为与终端一致的 UTF-8

由于数据库字符集是 ZHS16GBK,而终端是 UTF-8,正确的做法是让 Oracle 客户端知道输入是 UTF-8,由客户端自动完成 UTF-8 → ZHS16GBK 的转换:

1
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8

然后重新执行导出命令:

1
2
3
4
schemas=hie
directory=expdir
date_d=`date +%Y-%m-%d`
expdp \"/ as sysdba\" directory=$directory tables=\"hie.学生成绩表\" dumpfile=学生成绩表_${date_d}.dmp logfile=expdp_学生成绩表_${date_d}.log exclude=statistics
  • Title: expdp无法导出中文表名数据的解决方法
  • Author: 𝓓𝓸𝓷
  • Created at : 2026-11-12 19:20:35
  • Updated at : 2026-11-13 13:40:32
  • Link: https://www.zhangdong.me/exports-data-with-chinese-table-names.html
  • License: This work is licensed under CC BY-NC-SA 4.0.
评论