如何从 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: 2012 年 01 月
最佳答案
如果您使用的是 15.5 之前的 Sybase ASE,那么最好的选择是 create views在与您希望提取的列相匹配的表上,然后您可以从这些 View 中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
关于sybase - 如何 bcp 出几列而不是所有列? (赛贝斯),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22797335/