导出小写的表
上一篇 / 下一篇 2008-02-02 16:06:49 / 个人分类:ORACLE
记录一下exp碰到小写表的时候如何处理。
问题本来不复杂,但是由于在shell中使用特殊符合需要使用转义符,加上Oracle的exp语法限制,使得导出语句的格式比较特殊。
SQL> CREATE TABLE "t" (ID NUMBER);
表已创建。
SQL> INSERT INTO "t" VALUES (1);
已创建1行。
SQL> COMMIT;
提交完成。
SQL> SELECT * FROM t;
8SdtL'xdu;o f|0SELECT * FROM tITPUB个人空间W
q(oPFjr5H8[
*ITPUB个人空间+mF%O9n(M?'i/\/[H
第1行出现错误:ITPUB个人空间9V-Z~"{V3w
ORA-00942:表或视图不存在
ITPUB个人空间:oWNHfQaP!J
SQL> SELECT * FROM "t";
IDITPUB个人空间7o%zi|8aF/A%K*Mj
----------ITPUB个人空间Zr)|-|)|[0Q
1
在SQL中只需要加上双引号就可以处理小写的情况,但是在exp中就不是这么简单了。
[oracle@localhost ~]$ exp test/test file=t.dmp tables=t
Export: Release
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
k0JL7r
JYZ3Y2O0连接到: Oracle9i Enterprise Edition Release
,L+n!Z5^[!d6le0With the Partitioning, OLAP and Oracle Data Mining optionsITPUB个人空间t
XpVSS']nJB
r,J
JServer Release 9.2.0.4.0 - ProductionITPUB个人空间rOH*p _t!{
已导出ZHS16GBK字符集和AL16UTF16 NCHAR字符集
即将导出指定的表通过常规路径...
m@F*~F:`*EW0EXP-00011: TEST.T不存在ITPUB个人空间H6Qm
_b?,G8N%L3G
导出成功终止,但出现警告。
直接导出肯定是不行的,那么和SQL中一样加上双引号呢:
[oracle@localhost ~]$ exp test/test file=t.dmp tables="t"
Export: Release
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
{/sw/u7v5SCxJj0连接到: Oracle9i Enterprise Edition Release
With the Partitioning, OLAP and Oracle Data Mining optionsITPUB个人空间[ R6a4g_+jeBl
JServer Release 9.2.0.4.0 - Production
w_Z$z;g {
D;z0已导出ZHS16GBK字符集和AL16UTF16 NCHAR字符集
即将导出指定的表通过常规路径...
K
~Z'y-N&iP*cg0EXP-00011: TEST.T不存在ITPUB个人空间F
Z}7I0PQ&FH"J
导出成功终止,但出现警告。
导出仍然失败,从导出的输出就可以看到,双引号并没有起作用。
对于shell命令,使用双引号等特殊的字符需要’\’来进行转义,加上转义符再次尝试:
[oracle@localhost ~]$ exp test/test file=t.dmp tables=\"t\"
Export: Release
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
ITPUB个人空间{R%}c3qw
连接到: Oracle9i Enterprise Edition Release
;w-[,y^v8Q%Y0With the Partitioning, OLAP and Oracle Data Mining optionsITPUB个人空间N-xz7DY3r-C
JServer Release 9.2.0.4.0 - ProductionITPUB个人空间"z!{Y^
ZQR9}M
已导出ZHS16GBK字符集和AL16UTF16 NCHAR字符集
即将导出指定的表通过常规路径...ITPUB个人空间5U&OD \!D
EXP-00011: TEST.T不存在
7W
G9^iMJI0导出成功终止,但出现警告。
显然当前的设置还是没有生效。考虑到在使用QUERY方式导出的时候,QUERY后面的整个WHERE语句都是放在双引号中的,那么这个双引号应该只是表示参数的输入范围,而没有被送到Oracle内部的SQL引擎中。
看来一对双引号是不够的,尝试增加一对:
[oracle@localhost ~]$ exp test/test file=t.dmp tables=\"\"t\"\"
Export: Release
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
ITPUB个人空间*Q)O&^Az
连接到: Oracle9i Enterprise Edition Release
With the Partitioning, OLAP and Oracle Data Mining optionsITPUB个人空间$R#D-v2v;n'w}B
JServer Release 9.2.0.4.0 - ProductionITPUB个人空间.z&LP'\XKP
已导出ZHS16GBK字符集和AL16UTF16 NCHAR字符集
即将导出指定的表通过常规路径...ITPUB个人空间Dd/L6T.Jb
EXP-00019:处理参数失败,有关帮助请键入'EXP HELP=Y'ITPUB个人空间C-H\&vU;p
EXP-00011: TEST.T不存在
+x\8n#eT9F|b0导出成功终止,但出现警告。
看来这里的双引号效果和SQL语句中的单引号效果一致,为了输入一个双引号,需要两个双引号。
[oracle@localhost ~]$ exp test/test file=t.dmp tables=\"\"\"t\"\"\"
Export: Release
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
.TAp7e/JWd0连接到: Oracle9i Enterprise Edition Release
With the Partitioning, OLAP and Oracle Data Mining optionsITPUB个人空间`1K,?'Vw+zKNv;W
JServer Release 9.2.0.4.0 - ProductionITPUB个人空间N$h_ P8AHC`
h
已导出ZHS16GBK字符集和AL16UTF16 NCHAR字符集
即将导出指定的表通过常规路径...ITPUB个人空间A&J+HX!q*J Hh6]
. .正在导出表 t 0行被导出ITPUB个人空间R8w9_aAXc
在没有警告的情况下成功终止导出。
终于导出成功了,为了验证刚才的推断,再创建一张测试表:
SQL> CREATE TABLE "TesT1" (ID NUMBER);
表已创建。
下面两种方法都可以成功的导出t和TesT1表:
[oracle@localhost ~]$ exp test/test file=t.dmp tables=\"\"\"t\"\"\",\"T\"\"es\"\"T1\"
Export: Release
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
ITPUB个人空间5V$jf-R%d-D
连接到: Oracle9i Enterprise Edition Release
With the Partitioning, OLAP and Oracle Data Mining options
}Jwx.G$K7t pJ0JServer Release 9.2.0.4.0 - Production
[ k
N'i%@#yb3u.f0已导出ZHS16GBK字符集和AL16UTF16 NCHAR字符集
即将导出指定的表通过常规路径...ITPUB个人空间G\m EG$@3F$fu
. .正在导出表 t 1行被导出
DN Q:`3?zvH,j&b0. .正在导出表 TesT1 0行被导出
K:HWAkm8g0在没有警告的情况下成功终止导出。ITPUB个人空间w_A%rM/fd+x
[oracle@localhost ~]$ exp test/test file=t.dmp tables=\"\"\"t\"\"\",\"\"\"TesT1\"\"\"
Export: Release
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
ITPUB个人空间3_]!f-DA&D ow9L
连接到: Oracle9i Enterprise Edition Release
With the Partitioning, OLAP and Oracle Data Mining options
:hR7es6b)]B0JServer Release 9.2.0.4.0 - ProductionITPUB个人空间8pP]4s:nYH2f1Q
已导出ZHS16GBK字符集和AL16UTF16 NCHAR字符集
即将导出指定的表通过常规路径...
/_R-hx3X9k0. .正在导出表 t 1行被导出
rzRo:g
Q,t4O0. .正在导出表 TesT1 0行被导出
/_h)XginJT[_0在没有警告的情况下成功终止导出。
导入论坛 引用链接 收藏 分享给好友 推荐到圈子 管理 举报
TAG:
