我正在从带有长文本列的表格中进行选择。我想将长行包装到最大行长。
从:
SELECT * FROM test;
test_id | text
--------+-----------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris lorem
Run Code Online (Sandbox Code Playgroud)
到:
test_id | text
--------+-----------------------------
1 | Lorem ipsum dolor sit amet,+
| consectetur adipiscing elit+
| . Mauris lorem
Run Code Online (Sandbox Code Playgroud)
小智 37
如果您使用的是psql命令行工具,请先发出以下命令:
\pset format wrapped
Run Code Online (Sandbox Code Playgroud)
然后它应该将长行包裹到您的终端窗口,如下所示:
test_id | text
--------+-----------------------------
1 | Lorem ipsum dolor sit amet,.
|.consectetur adipiscing elit.
|.. Mauris lorem
Run Code Online (Sandbox Code Playgroud)
您还可以设置要换行的列数
\pset columns 100
Run Code Online (Sandbox Code Playgroud)
您可以将点更改为椭圆
\pset linestyle unicode
Run Code Online (Sandbox Code Playgroud)
更多信息:http : //www.postgresql.org/docs/current/static/app-psql.html
小智 12
我的回答不会直接回答你的问题,因为我不认为 psql 本身可以专门做到这一点。但是,\x将打开扩展输出,这将使您的值如下所示:
-[ RECORD 1 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
id | 1
longstring | This is a long string of text that will be quite long and most likely be very annoying to read if you are viewing results with more than at most a few columns of data. Words words words words words words lorem ipsum.
Run Code Online (Sandbox Code Playgroud)
您还可以将寻呼机配置为不换行。
要切换到正常显示,只需再次发出命令 \x。说明:
\x [on|off|auto] toggle expanded output (currently off)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
30642 次 |
| 最近记录: |