我申请这个blog是为了督促自己,把自己平时的一些想法和思考结果保留下来。 本博客所有内容均为原创,如有转载请注明作者和出处

导出小写的表

上一篇 / 下一篇  2008-02-02 16:06:49 / 个人分类:ORACLE

记录一下exp碰到小写表的时候如何处理。

 

 

问题本来不复杂,但是由于在shell中使用特殊符合需要使用转义符,加上Oracleexp语法限制,使得导出语句的格式比较特殊。

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(oP Fj r5H8[
              *ITPUB个人空间+mF%O9n(M?'i/\/[H
1行出现错误:ITPUB个人空间9V-Z~"{V3w
ORA-00942:
表或视图不存在

ITPUB个人空间:oWNHfQa P!J
SQL> SELECT * FROM "t";

        IDITPUB个人空间7o%zi|8aF/A%K*Mj
----------ITPUB个人空间Z r)|-|)|[0Q
         1

SQL中只需要加上双引号就可以处理小写的情况,但是在exp中就不是这么简单了。

[oracle@localhost ~]$ exp test/test file=t.dmp tables=t

Export: Release9.2.0.4.0 - Production on星期六22 14:51:14 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


k0JL7r JYZ3Y2O0
连接到: Oracle9i Enterprise Edition Release9.2.0.4.0 - Production
,L+n!Z5^[!d6le0With the Partitioning, OLAP and Oracle Data Mining optionsITPUB个人空间t X pVSS']n JB 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: Release9.2.0.4.0 - Production on星期六22 14:51:19 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


{/sw/u7v5SCxJj0
连接到: Oracle9i Enterprise Edition Release9.2.0.4.0 - ProductionITPUB个人空间2nS:Q+Br e
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: Release9.2.0.4.0 - Production on星期六22 14:51:30 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

ITPUB个人空间{R%} c3qw
连接到: Oracle9i Enterprise Edition Release9.2.0.4.0 - Production
;w-[,y^v8Q%Y0With the Partitioning, OLAP and Oracle Data Mining optionsITPUB个人空间N-x z7DY3r-C
JServer Release 9.2.0.4.0 - ProductionITPUB个人空间"z!{Y^ ZQR9}M
已导出ZHS16GBK字符集和AL16UTF16 NCHAR字符集

即将导出指定的表通过常规路径...ITPUB个人空间5U&O D\!D
EXP-00011: TEST.T
不存在

7W G9^iM JI0
导出成功终止,但出现警告。

显然当前的设置还是没有生效。考虑到在使用QUERY方式导出的时候,QUERY后面的整个WHERE语句都是放在双引号中的,那么这个双引号应该只是表示参数的输入范围,而没有被送到Oracle内部的SQL引擎中。

看来一对双引号是不够的,尝试增加一对:

[oracle@localhost ~]$ exp test/test file=t.dmp tables=\"\"t\"\"

Export: Release9.2.0.4.0 - Production on星期六22 15:43:33 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

ITPUB个人空间*Q)O&^Az
连接到: Oracle9i Enterprise Edition Release9.2.0.4.0 - ProductionITPUB个人空间h2y&PbT I H
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: Release9.2.0.4.0 - Production on星期六22 14:51:49 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


.TA p7e/JWd0
连接到: Oracle9i Enterprise Edition Release9.2.0.4.0 - ProductionITPUB个人空间 rlZ U8j9{p
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);

表已创建。

下面两种方法都可以成功的导出tTesT1表:

[oracle@localhost ~]$ exp test/test file=t.dmp tables=\"\"\"t\"\"\",\"T\"\"es\"\"T1\"

Export: Release9.2.0.4.0 - Production on星期六22 15:56:24 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

ITPUB个人空间5V$jf-R%d-D
连接到: Oracle9i Enterprise Edition Release9.2.0.4.0 - ProductionITPUB个人空间@&LZ|4lo/?5B
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?z vH,j&b0. .
正在导出表                           TesT1          0行被导出
K:HWAkm8g0
在没有警告的情况下成功终止导出。ITPUB个人空间w_A%rM/fd+x
[oracle@localhost ~]$ exp test/test file=t.dmp tables=\"\"\"t\"\"\",\"\"\"TesT1\"\"\"

Export: Release9.2.0.4.0 - Production on星期六22 15:56:50 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

ITPUB个人空间3_]!f-DA&D ow9L
连接到: Oracle9i Enterprise Edition Release9.2.0.4.0 - ProductionITPUB个人空间%P iqC'J4ifjE
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行被导出

rz Ro:g Q,t4O0. .
正在导出表                           TesT1          0行被导出
/_h)XginJT[_0
在没有警告的情况下成功终止导出。

 


TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

Open Toolbar