Render rows in a single column in psql.
Created on April 7, 2025
Updated on April 9, 2025
psql
In the first example, the content does not fit the width of the box. You have to scroll horizontally to see all the output.
In many cases, the display will break the lines instead of making the display scrollable. In such a case, it’s a bad experience to examine your data…
SELECT id, path, title, category, created_at
FROM website.til;
id | path | title | category | created_at
----+----------------------------+----------------------------------------------+-----------------+------------
2 | http-form-representation | How Form Submissions Are Represented In HTTP | networking/http | 2025-04-06
1 | postges-roles-users-groups | Postgres: Users And Groups Are Roles | postgres | 2025-04-06
(2 rows)
After setting \x
, the rows will be displayed in columns.
\x on
Expanded display is on.
SELECT id, path, title, category, created_at
FROM website.til;
-[ RECORD 1 ]--------------------------------------------
id | 2
path | http-form-representation
title | How Form Submissions Are Represented In HTTP
category | networking/http
created_at | 2025-04-06
-[ RECORD 2 ]--------------------------------------------
id | 1
path | postges-roles-users-groups
title | Postgres: Users And Groups Are Roles
category | postgres
created_at | 2025-04-06
Bonus: \t
makes the output a bit leaner by removing the [ RECORD N ]
.
\t on
SELECT id, path, title, category, created_at
FROM website.til;
id | 2
path | http-form-representation
title | How Form Submissions Are Represented In HTTP
category | networking/http
created_at | 2025-04-06
-----------+---------------------------------------------
id | 1
path | postges-roles-users-groups
title | Postgres: Users And Groups Are Roles
category | postgres
created_at | 2025-04-06