Harry Boy
Harry Boy

Reputation: 4745

Exit a SQLite 3 database

I have an SQLite 3 database in SUSE Linux.

It's stuck at the command prompt like so:

sqlite> q
   ...> exit
   ...> .exit
   ...> quit
   ...> .quit

How do I exit out of the database?

Upvotes: 121

Views: 126263

Answers (9)

JuliaJ
JuliaJ

Reputation: 97

In windows 11 command prompt, I just use CTRL + C.

Upvotes: 0

Rahul Goyal
Rahul Goyal

Reputation: 1

enter image description here

someitimes quotes (") may not be closed, So we can try "; by closing the quote and adding a semicolon to indicate that it is the end of query.

Upvotes: 0

Vishal Kumar Sahu
Vishal Kumar Sahu

Reputation: 1396

Tldr;

Use a ; (semicolon) press enter then use .exit. Done!

The invincible trap

You have entered multiline command input. To exit the command multiline input use a semicaolon (;) to complete your command. And then use .exit to exit from sqlite commandline or continue with what you want to do.

sqlite>
sqlite> cd
   ...>
   ...> .exit
   ...> .exit
   ...> exit()
   ...> ;  # This semicolon completes the incomplete cd command
Error: near "cd": syntax error
sqlite> .exit

see the Example

Upvotes: 30

The.Wolfgang.Grimmer
The.Wolfgang.Grimmer

Reputation: 1351

Running .help .exit shows

.exit ?CODE?             Exit this program with return-code CODE

With that said, running .exit 0 exits it from sqlite3 console.

Alternatively, simply use .quit or CTRL + D

Upvotes: 1

Banafshe Bamdad
Banafshe Bamdad

Reputation: 529

To see all SQLite commands in the SQLite prompt, use the .help command. Before stucking at the command prompt, you can use the .exit command.

Upvotes: 4

user8616916
user8616916

Reputation: 73

For the Windows command prompt, pressing Ctrl + Z and then pressing Enter worked for me. It directly brought me out of the sqlite> prompt.

If you want to stay at the sqlite> prompt, but just come out of the inner prompt, ...>, then as JimmyB has said, type ; and press Enter. It just completes your statement, the prompt ...> shows it is expecting more in the statement so far typed, as SQLite statements always end with a semicolon.

Upvotes: 5

Kurt Van den Branden
Kurt Van den Branden

Reputation: 12943

You can terminate the SQLite 3 program by typing your system's end-of-file character (usually a Ctrl + D). Use the interrupt character (usually a Ctrl + C) to stop a long-running SQL statement.

Upvotes: 8

JimmyB
JimmyB

Reputation: 12610

Type ; + Enter to terminate the current statement (will give an error message because what you typed so far is not a valid statement but never mind). Then .quit + Enter.

Note that in SQLite 3, SQL statements must be terminated with a delimiter, which is ; by default. The non-SQL commands, which start with a ., do not need to be terminated this way, but they are considered complete as soon as Enter is pressed.

If a command does not start with a . and Enter is pressed without the SQL termination character, the CLI client displays the "continuation prompt" (...> in your case) and expects the SQL command to be continued on the following line(s) until it is properly terminated.

See also Command Line Shell For SQLite.

Upvotes: 154

njachowski
njachowski

Reputation: 1167

Ctrl + D will get you out of the SQLite 3 database command prompt.

That is: hold the "Ctrl" button then press the lowercase d key on your keyboard at the same time and you will escape the SQLite 3 command prompt.

Upvotes: 66

Related Questions