All quizzesEasy
PostgreSQL Basics — Series 3
Preview — 3 of 10 questions
What does the \e meta-command do in psql?
AIt opens the current query buffer (or the last executed query) in your configured external editor ($EDITOR), letting you edit a longer or more complex query comfortably before it's run back in psql when you save and exit
BIt executes the last query again, unchanged
CIt explains the query plan for the last statement, equivalent to EXPLAIN
DIt exports the last query's results to a file named e.sql
What's the difference between typing \? and \h (or \h SELECT) in psql?
AThey're exact synonyms; both show the same output
B\? lists every table in the database; \h lists every function
C\? shows help for psql's own backslash meta-commands (\d, \c, \x, and so on); \h (optionally followed by a SQL command name) shows help for SQL syntax itself — \h SELECT prints SELECT's full syntax reference, something \? doesn't cover at all
D\? only works in interactive mode; \h only works in scripts
What does \set my_id 42 followed by SELECT * FROM users WHERE id = :my_id; do?
A\set defines a client-side psql variable; :my_id in a following SQL statement is substituted, before the query is sent to the server, with the variable's current value (42 here) — a lightweight way to parameterize ad-hoc interactive queries or scripts without repeating literal values everywhere
BIt's invalid syntax — psql variables can only be used inside \set commands themselves
C\set creates a genuine PostgreSQL session variable, readable from any other connected session too
D:my_id is standard SQL bind-parameter syntax, unrelated to psql's \set command
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.