如何bcp出几列而不是所有列? (的Sybase)

时间:2014-04-01 21:35:03

标签: sybase sybase-ase

如何从Sybase(Adaptive Server Enterprise / 15.7.0)表中仅删除几列?以下是Sybase bcp帮助屏幕。它不接受SQL作为输入。我想bcp出许多表的唯一索引的所有列。或者有其他方法吗?

usage: bcp [[db_name.]owner.]table_name[:slice_num] [partition pname] {in | out}
 [filename]
        [-m maxerrors] [-f formatfile] [-e errfile] [-d discardfileprefix]
        [-F firstrow] [-L lastrow] [-b batchsize]
        [-n] [-c] [-t field_terminator] [-r row_terminator]
        [-U username] [-P password] [-I interfaces_file] [-S server]
        [-a display_charset] [-z language] [-v]
        [-i input_file] [-o output_file]
        [-A packet size] [-J client character set]
        [-T text or image size] [-E] [-g id_start_value] [-N] [-W] [-X]
        [-M LabelName LabelValue] [-labeled]
        [-K keytab_file] [-R remote_server_principal] [-C]
        [-V [security_options]] [-Z security_mechanism] [-Q] [-Y]
        [-y sybase directory] [-x trusted.txt_file]
        [--clienterr errfile] [--maxconn maximum_connections]
        [--show-fi] [--hide-vcc]
        [--colpasswd [[[db_name.[owner].]table_name.]column_name [password]]]
        [--keypasswd [[db_name.[owner].]key_name [password]]]
        [--initstring ASE initialization string] [--quoted-fname]

版本为Adaptive Server Enterprise/15.7.0/EBF 20305 SMP ESD#01 Refresh#2/P/x86_64/Enterprise Linux//2927/64-bit/FBO/Fri Jun 22 09:38:01 2012

1 个答案:

答案 0 :(得分:2)

如果您使用的是版本15.5之前的Sybase ASE,那么您最好选择与您要提取的列匹配的表create views,然后您可以bcp从这些视图中选择。

create view titles_view 
as select title, type, price, pubdate 
from titles

bcp mydatabase..titles_view out titles_view -Uusername -Sservername -n

如果您使用的是SAP Sybase ASE 15.5或更高版本,则可以使用output命令将select语句的结果输​​出到文件中。

select *
from employee
go
output to employee.txt
format ASCII

output的语法和选项可在此处找到:Sybase ASE Reference Manual: Commands