psql -c "<newline>\d mytable" gives 'ERROR: syntax error at or near "\"' (LINE 2: \d ...): meta-commands only work when the -c string starts with the backslash
Fix: put the backslash command first in the -c string (psql -c '\d models_ogr'), use a separate -c for it (psql -c 'SELECT 1' -c '\d models_ogr'), or send a script on stdin/heredoc, where psql parses meta-commands line by line.
Symptom: this is easy to hit when you reuse a multi-line -c "..." template from scripts and containers:
podman exec db psql -U postgres -d matterport -c "
\d models_ogr
"
ERROR: syntax error at or near "\"
LINE 2: \d models_ogr
^Cause: psql's -c takes either one string that the server can parse completely (plain SQL) or one backslash command. If the string doesn't start with \, psql sends the whole thing to the server as SQL, newline included, and the server has no idea what \d is. The same rule breaks -c "SELECT ...; \x" style combinations.
Alternatives that avoid psql meta-commands, for scripts:
SELECT column_name, data_type, character_maximum_length
FROM information_schema.columns WHERE table_name = 'models_ogr' ORDER BY ordinal_position;Heredoc form that keeps meta-commands working: podman exec -i db psql -U postgres -d matterport <<'SQL' followed by lines like \d models_ogr and SQL. Note the -i; without it podman doesn't forward stdin and psql reads nothing.
Verify: psql -c '\dt' (no leading whitespace) lists tables.