NT及Unix 下exp 时候子查询写法

EXP 数据库数据 QUERY 选项使用问题

摘自http://www.dbonline.cn

问题:我知道在 Oracle8i 中,可以使用 QUERY 有选择地输出表数据。我想用 EXP 命令来实现,但没有成功。下面是我所写的命令,以及得到的错误信息:



exp ddd/ddd file=/dbf/u11/customer.dmp

tables=AASC.AST_CUSTOMER_KEEP

query='where CUA_TRANS_DTS <

add_months(sysdate, -6)'

table_export[2]: CUA_TRANS_DTS: not found. (没有找到)

答:操作系统不同,用来指定 QUERY= 参数的方法也不同。 WHERE 语句里面往往有很多特殊的字符,如 =.>.< 和空格等等。而 UNIX 和 Windows 操作系统中的外壳命令提示是不欢迎这些字符的,这些字符将被忽略。你应该根据不同的操作系统采用不用的方法。我一般使用带有 QUERY 选项的参数文件( PARFILE ),利用 PARFILE ,可以不考虑操作系统平台而使用完全相同的方法。

下面给出一个例子。我用 select * from all_objects 建立了一个表 T ,我希望输出所有 object_id 小于 5000 的行。在 Windows 中,必须这样做:

C:exp>exp userid=tkyte/tkyte tables=t

query="""where object_id < 5000"""

注意:在 windows 中,需要在 WHERE 语句的两端使用三个双引号。在 UNIX 中,必须这样做:

$ exp userid=/ tables=t query="where

object_id < 5000"

exp userid=/ tables=t parfile=exp.par

如果使用包含 query="where object_id < 5000" 的 PARFILE 文件,我可以在两个系统中使用相同的一个命令:

exp userid=/ tables=t parfile=exp.par

在两种操作系统中,完全相同。这相对于在不同的平台中使用不同的 QUERY 字符串容易多了。


__________________
qwerqwe

本文地址:http://www.apub.org/doc/2006/03/11/09/14/43/5968.html
原文出处:http://www.itpub.net/221227.html

============================================

For example, if user scott wants to export only those employees whose job title is salesman and whose salary is less than 1600, he could do the following (this example is UNIX-based):

 
  
 

Note:

Because the value of the QUERY parameter contains blanks, most operating systems require that the entire strings WHERE job='salesman' and sal<1600 be placed in double quotation marks or marked as a literal by some method. Operating system reserved characters also need to be preceded by an escape character. See your operating system-specific documentation for information about special and reserved characters on your system.

When executing this query, Export builds a SQL SELECT statement similar to the following:

 
 

例子(WINNT上执行通过):

exp system/system QUERY="WHERE b_id>=1 and b_id<1000" buffer=8192 tables=usr1.buget_t feedback=50 consistent=n compress=n filesize=2G log=buget_log file=(buget_1, buget_2)

QUERY

Default: none

This parameter allows you to select a subset of rows from a set of tables when doing a table mode export. The value of the query parameter is a string that contains a WHERE clause for a SQL SELECT statement that will be applied to all tables (or table partitions) listed in the TABLE parameter.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/35489/viewspace-84372/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/35489/viewspace-84372/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值