DEV Community

Stephen Charles Weiss
Stephen Charles Weiss

Posted on • Originally published at stephencharlesweiss.com on

8 2

Postgres Tuples Only

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 (\t).

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 | stephen@me.com |
  2 | fake user | fake@user.com |
Enter fullscreen mode Exit fullscreen mode

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.
Enter fullscreen mode Exit fullscreen mode

My query produced the table headers as expected:

db=> select * from users;
 id | name | email | password
---------+-----------+----------------+----------
  1 | stephen | stephen@me.com |
  2 | fake user | fake@user.com |
(2 rows)
Enter fullscreen mode Exit fullscreen mode

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.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (2)

Collapse
 
benjaminadk profile image
benjaminadk

Funny. I just did this and thought....what did I just break? Worthwhile post sir.

Collapse
 
beaumontyun profile image
beaumontyun

Nice and short post that landed on top of google search, so useful to know what happened when I accidentally pressed \t and thought "oh shit, what is this...?"

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay