If I type something wrong into psql
, default dbname=#
changes to either dbname-#
or dbname(#
and normal commands no longer work. How do I get it back to dbname=#
?
You tried to run a statement with unbalanced parentheses.
So psql
thinks you're going to write more of the same statement and is waiting for input.
psql
will not treat a semicolon as end-of-statement when there's an open quoted string, there are unbalanced parantheses, etc, since sometimes semicolons appear within statements in such cases. So ;
` won't work.
craig=> CREATE TABLE (
craig(>
craig(> ;
craig(>
Use \r
or \reset
to clear the in-progress query buffer.
Control-C has the same effect, but it'll also cancel an in-progress statement sent to the server, and on Windows it'll exit psql
completely. So you should prefer to use \r
:
craig=> CREATE TABLE (
craig(>
craig(> ;
craig(>
craig(> \r
Query buffer reset (cleared).
craig=>