利用QUERY选项输出数据我知道在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字符串容易多了。 

解决方案 »

  1.   

    unix:
    exp userid=user/pass@sid tables=ta query="\"where name='aaa'\"" file=./aaa.dmp
    windows
    exp userid=user/pass@sid tables=ta query="""where name='aaa'""" file=.\aaa.dmp
    windows
    exp userid=dbuser/pwd tables=ta query="""where name='aaa'""" 
    linux
    exp userid=dbuser/pwd tables=ta query=\"where name='aaa'\"
      

  2.   

    还是写PAR文件吧,在PAR文件里面对QUERY子句的格式是没那么多讲究的,也不分平台,只需用单引号把条件括起来即可。然后在做EXP的时候,指定PAR文件即可。
      

  3.   

    windows:  exp user/password file=a.dmp tables=(ta) query='where name=\'aaa\''
    注意后面不要有分号
      

  4.   

    谢谢各位
    我按照各位提供的方法试验了一下,结果导出成功,但是系统提示有警告:
    我的语句为:
    exp scott/tiger file=d:\emp.dmp tables = emp query = """ where job = 'SALESMAN' """
    系统提示结果为:
    EXP-00091:正在导出可疑的统计信息。
    导出成功终止,但出现警告。我查了帮助EXP-00091
    EXP-00091 Exporting questionable statistics
    Cause: Export was able to export statistics, but the statistics may not be
    useable. The statistics are questionable because one or more of the following
    happened during export: a row error occurred, client character set orNCHARSET does not match with the server, a query clause was specified on
    export, only certain partitions or subpartitions were exported, or a fatal error
    occurred while processing a table.
    Action: To export non-questionable statistics, change the client character set or
    NCHARSET to match the server, export with no query clause, or export
    complete tables. If desired, import parameters can be supplied so that only
    non-questionable statistics will be imported, and all questionable statistics will
    be recalculated.
    大概的意思是客户端与服务器的字符集不一致,但是我的服务器就装在本机,怎么办呢?