snippetsqlMajor
How to wrap long lines when SELECTing SQL text columns?
Viewed 0 times
howcolumnssqltextlongselectingwhenwraplines
Problem
I'm selecting from a table with long text columns. I'd like to wrap long lines to a maximum line length.
From:
To:
From:
SELECT * FROM test;
test_id | text
--------+-----------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris loremTo:
test_id | text
--------+-----------------------------
1 | Lorem ipsum dolor sit amet,+
| consectetur adipiscing elit+
| . Mauris loremSolution
If you're using the
It should then wrap long lines to your terminal window like so:
You can also set the number of columns to wrap to with
and you can change the dots to ellipses with
More info: http://www.postgresql.org/docs/current/static/app-psql.html
psql command line tool, issue this command first:\pset format wrappedIt should then wrap long lines to your terminal window like so:
test_id | text
--------+-----------------------------
1 | Lorem ipsum dolor sit amet,.
|.consectetur adipiscing elit.
|.. Mauris loremYou can also set the number of columns to wrap to with
\pset columns 100and you can change the dots to ellipses with
\pset linestyle unicodeMore info: http://www.postgresql.org/docs/current/static/app-psql.html
Code Snippets
\pset format wrappedtest_id | text
--------+-----------------------------
1 | Lorem ipsum dolor sit amet,.
|.consectetur adipiscing elit.
|.. Mauris lorem\pset columns 100\pset linestyle unicodeContext
StackExchange Database Administrators Q#1728, answer score: 47
Revisions (0)
No revisions yet.