Beginner LevelPostgreSQL
What are psql CLI meta-commands (\d, \c, \l, \x, \ef)?
❓ Interview Prompt: Explain psql interactive CLI tool, backslash meta-commands (\d, \dt, \c, \l, \x, \timing, \ef), and script execution.
psql is the native interactive terminal for PostgreSQL. Commands starting with a backslash ('\') are meta-commands executed directly by psql:
•
'\c dbname': Connect to target database.
•
'\l': List all databases.
•
'\d table': Describe table schema, indexes, and constraints.
•
'\x': Toggle expanded auto-display mode (ideal for reading wide rows!).
•
'\timing': Toggle execution timing output for queries.
Code Implementation Example
sql
-- psql interactive commands
\c ecommerce_db
\d orders
\x auto
\timing on
SELECT * FROM orders LIMIT 1;💡Executing psql meta-commands for schema inspection.
🎯 Interview Key Takeaway
Use \d to describe table definitions and \x to view wide rows in psql.
#psql#CLI#Meta-Commands#Beginner
Back to all PostgreSQL Questions→