sybase - 如何 bcp 出几列而不是所有列? (赛贝斯)

标签 sybase sap-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: 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/

相关文章:

java - sybase数据库要一次性更新吗?

linux - 无法连接到 Sybase 服务器

sybase - 删除 ASE 列中的空格

mysql - 为什么字符串搜索在 sybase 中区分大小写,而在许多其他数据库中则不区分大小写

iphone - 从 libMo.a 中的 PlatCompress(enumCompressOperation, CompressCookie*, void*, long) 引用的体系结构 i386 : "_deflate", 的 undefined symbol

delphi - 带有 Delphi 和 dbExpress 的 ASE Syabse 服务器版本

sap-ase - 如果存在非空或默认值的更改表语句不起作用

sql - Sybase - FROM 子句中的子查询

java - 在Java中获取以秒为单位的日期表示

SQL父/子递归调用还是联合?