How to go back from user '> to user=> after you enter a wrong command in psql

Viewed 237

What I have tried that works would be exiting psql using \q and logging in again using psql -d postgres -U user, but that's kind of a hassle.

So my question would be, is there a better way to go back to the user=> from user'> because with the latter you won't be able to use any psql commands.

1 Answers

The prompt dbname'> indicates that you started a string literal (entered a single quote) but didn't finish it. You can get out of that by

  1. closing the string literal and resetting the query buffer:

    '\r
    
  2. hitting Ctrl+C or whatever sends the SIGINT signal on your terminal

Related