Press "Enter" to skip to content

psql Meta-Commands

Ian Parker shows off some meta-commands:

If you manage PostgreSQL from a terminal you already know psql, the interactive client that ships with every installation. Most developers use it for the basics—running SELECT statements, loading a .sql file, maybe poking around with \dt to see which tables exist.

Beneath that familiar surface, though, psql hides a rich toolbox of meta-commands. These commands, all prefixed with a backslash, live inside the client. They’re not SQL, they’re shortcuts built into psql itself, and they can make everyday tasks faster and far less error-prone.

Read on for six of these, including examples like \watch to view something with periodic refresh.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.