psql的备用输出格式 [英] Alternate output format for psql

查看:127
本文介绍了psql的备用输出格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ubuntu上使用PostgreSQL 8.4。我有一个表格,其中有列 c1 cN 。列足够宽,选择所有列都会导致一行查询结果多次包装。因此,输出很难读取。

I am using PostgreSQL 8.4 on Ubuntu. I have a table with columns c1 through cN. The columns are wide enough that selecting all columns causes a row of query results to wrap multiple times. Consequently, the output is hard to read.

当查询结果仅占几行时,如果查看查询结果以使查询的每一列都非常方便。每行都在单独的一行上,例如

When the query results constitute just a few rows, it would be convenient if I could view the query results such that each column of each row is on a separate line, e.g.

 c1: <value of row 1's c1>
 c2: <value of row 1's c1>
 ...
 cN: <value of row 1's cN>
 ---- some kind of delimiter ----
 c1: <value of row 2's c1>
 etc.

我在不希望安装的服务器上运行这些查询任何其他软件。有一个psql设置可以让我做类似的事情吗?

I am running these queries on a server where I would prefer not to install any additional software. Is there a psql setting that will let me do something like that?

推荐答案

我只需要花更多时间盯着文档。该命令:

I just needed to spend more time staring at the documentation. This command:

\x on

完全可以满足我的要求。以下是一些示例输出:

will do exactly what I wanted. Here is some sample output:

select * from dda where u_id=24 and dda_is_deleted='f';
-[ RECORD 1 ]------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dda_id             | 1121
u_id               | 24
ab_id              | 10304
dda_type           | CHECKING
dda_status         | PENDING_VERIFICATION
dda_is_deleted     | f
dda_verify_op_id   | 44938
version            | 2
created            | 2012-03-06 21:37:50.585845
modified           | 2012-03-06 21:37:50.593425
c_id               | 
dda_nickname       | 
dda_account_name   | 
cu_id              | 1
abd_id             | 

这篇关于psql的备用输出格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆