1

If I start typing a multi-line command on the SQLite shell, and change my mind mid-way, how do I get back to shell prompt again without causing SQLite to execute the current command?

sqlite> INSERT INTO
   ...> mytable VALUES
   ...> ^C                  <---- changed my mind here, but ^C doesn't work
   ...>;                    <---- had to type ; to end the command
Error: near ";": syntax error   <---- want to avoid this

As you can see above, SQLite tried to execute invalid command. Is there a way I can press a key combination and return to a clean prompt again?

1

Try pressing CtrlU which will erase from the cursor to the beginning of the line. To erase from the cursor to the end of the line, if needed: CtrlK

  • Thanks, but any way to totally clear the command buffer? Previous lines too! – slowpoison Jun 5 '12 at 0:41
  • @slowpoison: The keystrokes I listed are from the readline library which SQLite uses if it's available. Readline doesn't have a clear-history function as far as I know. – Dennis Williamson Jun 5 '12 at 0:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.