Search code examples
psql

How to show help on backslash commands in psql for `\c` command?


When I inside psql I can invoke help with \?.

...
Help
  \? [commands]          show help on backslash commands
  \? options             show help on psql command-line options
  \? variables           show help on special variables
  \h [NAME]              help on syntax of SQL commands, * for all commands
...

But when I tried to get help only for \c command \? \c I get same output as it was for invoked \?.

How to show help on backslash commands in psql for \c?


Solution

  • If you look at the documentation, you'll see

    ? [ topic ]

    Shows help information. The optional topic parameter (defaulting to commands) selects which part of psql is explained: commands describes psql's backslash commands; options describes the command-line options that can be passed to psql; and variables shows help about psql configuration variables.

    So you cannot display help on a single backslash command; your options are:

    \? commands
    \? options
    \? variables
    

    If you look at the \? output, you will note that \? [command] has command in lower case. In other cases, where you can supply a variable argument to the command, it is shown in upper case, for example \e [FILE] [LINE]. So that command means the literal string command, it is not a placeholder for a command.

    I freely admit that this is somewhat confusing, but I cannot think of an improvement that is short enough.