官术网_书友最值得收藏!

Displaying output as CSV

For those of you using psql to work with PostgreSQL, there is more—psql can't display data in CSV format, as shown in the next listing:

test=# \pset format csv
Output format is csv.
test=# SELECT id, id FROM generate_series(1, 4) AS id;
id,id
1,1
2,2
3,3
4,4

This is especially useful if you are using psql in a shell script and if you are piping data from one program to the next. If you always want to get data in CSV format, you can add the pset command to your .psqlrc file. 

主站蜘蛛池模板: 遵义市| 襄垣县| 惠来县| 平乡县| 高尔夫| 西宁市| 澄迈县| 泌阳县| 台北市| 连平县| 洞口县| 天津市| 三穗县| 许昌市| 拜城县| 南康市| 米脂县| 绥芬河市| 洛浦县| 乌拉特后旗| 耿马| 高邮市| 高雄市| 克拉玛依市| 古蔺县| 山东| 湖州市| 江阴市| 多伦县| 辽阳市| 清水河县| 白河县| 施甸县| 乐山市| 龙南县| 沙田区| 广东省| 许昌市| 海林市| 福海县| 大姚县|