November 25, 2019
If you’re just learning how to use Postgres from the terminal (as I am), sometimes you click the wrong button and don’t know what it does, then later, you realize something’s not quite right but don’t know how to fix it.
That’s what happened recently when I accidentally turned tuples only on (
When I queried a table, only the results printed - not the column headers.
So, when querying a user table, I got the following:
onething=> select * from users; 1 | stephen | email@example.com | 2 | fake user | firstname.lastname@example.org |
It’s not a complicated table, and it’s test data - so I could put the pieces together, but I knew one day, I’d want to see the headers.
That’s when I found that I’d accidentally fat-fingered turning Tuples only on.
Once I reversed it:
db=> \t Tuples only is off.
My query produced the table headers as expected:
db=> select * from users; id | name | email | password ----+-----------+----------------+---------- 1 | stephen | email@example.com | 2 | fake user | firstname.lastname@example.org | (2 rows)
To see the full list of options us the
\? option from the command line, but for more, you can see the documentation on the interactive terminal on the Postgres site.
And now I know about tuples only mode in Postgres! Won’t make that mistake again.
Thanks for reading! My name's Stephen Weiss. I live in Chicago with my wife, Kate, and dog, Finn.
Click here to see the archives of my weeks in review and sign up yourself!