2014-04-01 17 views
3

如何僅從Sybase(Adaptive Server Enterprise/15.7.0)表中僅列出幾列?以下是Sybase bcp幫助屏幕。它不接受SQL作爲輸入。我想列出許多表的唯一索引的所有列。還是有其他方法嗎?如何生成幾列而不是所有列? (Sybase)

 
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

+0

創建FORMATFILE並將其提供給'-f'參數...?至少這是它在sybase的姐妹數據庫SqlServer中的工作方式:http://msdn.microsoft.com/en-us/library/aa337558%28SQL.90%29.aspx – rene

+0

當bcp出來時,可以使用格式文件嗎? – ca9163d9

+0

是啊,我無法想象爲什麼它不應該,但我想成爲DBA(又名開發人員),所以我可能會誤會...... – rene

回答

2

如果您在之前使用Sybase ASE 15.5的版本,那麼你最好的選擇是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

+0

輸出到'表格很好嗎?它可以輸出到網絡共享驅動器嗎? – ca9163d9

+0

版本爲「Adaptive Server Enterprise/15.7.0/EBF 20305 SMP ESD#01 Refresh#2/P/x86_64/Enterprise Linux // 2927/64位/ FBO /星期五Jun 22 09:38:01 2012」 – ca9163d9

+0

老實說,我沒有使用輸出的好運氣,所以我不知道性能或網絡驅動器的選擇。它使用isql的GUI版本,我主要使用CLI版本的isql。 –

相關問題