What options are there for the sqsh style “csv” (o

2019-07-29 19:27发布

With the DB tool sqsh, I want to get the column names and the data tab delimited.

The bcp option does not include the column names.

The csv option includes the column names, but uses comma as the separate (doh). Is there a way to change it?

Currently looking to post-process the file to change the commas to tabs (ignoring the commas within strings...).

标签: sqsh
2条回答
冷血范
2楼-- · 2019-07-29 19:47

Please note that since sqsh version 2.5 it is now possible to assign control characters to some variables like colsep, linesep, bcp_colsep and bcp_rowsep. So the

\set colsep="\t"

should work now properly with sqsh-2.5.

查看更多
你好瞎i
3楼-- · 2019-07-29 20:11

You can \set colsep="\t" to change the separator for the standard output to tab.

Edit: \t didn’t work (in my cygwin), so I used <CTRL-V><TAB>. That works:

[228] > \set colsep=" " -- Hit CTRL-V then <TAB> here.
[229] > select 'ABC' as STRING, 12 as INT;
    STRING  INT
    ------  -----------
    ABC              12

(1 row affected)
查看更多
登录 后发表回答