I made a mistake writing a command at the SQLite command prompt, which I now want to abort, this is how my command line looks

sqlite> select * from todos'
   ...> '
   ...> ;^C

In this case, likely because I have opened a quote, I can't even hit ENTER to run the command. I just get a line continuation, that would still be less than ideal because I would be having to run bad code and cause and error, just to regain control of the prompt.
How can I cancel the line/command and get returned back to a prompt?

  • Maybe ^D will close stdin for sqlite and make it exit... Jun 21, 2016 at 8:49
  • 2
    @Ralph ctrl D makes sqlite exit the entire session, including losing any in memory databases - if you hapoen to be running any. Jun 21, 2016 at 8:53

1 Answer 1


The sqlite3 interface uses the ReadLine library for command line editing. You can erase a full line with Ctrl+U but once you have pressed Enter, the line has been accepted and is no longer editable.

As you've noticed, sending Ctrl+D will prompt the client to exit, which is not what you want.

Your best bet is to

  1. close any string, and then,
  2. before issuing a final ;, generate a deliberate syntax error.

In your example:

sqlite> select * from todos'
   ...> '
   ...> *** I made a mistake
   ...> ;
Error: near "*": syntax error

This will ensure that nothing gets executed, and it will leave you in the SQLite session with any temporary tables intact.

  • 1
    thanks, yes I thought that might be best workaround Jun 21, 2016 at 9:30
  • 2
    If you have pressed enter after an arrow key, i.e., you have something like > ^[[A and then ...>, then you have to close the brackets to cancel that: > ]];. It really should support Ctrl+C for this. It's obnoxious this way.
    – mxmlnkn
    Sep 22, 2019 at 11:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .