Skip to main content

Exiting the CLI

Finishing a CLI session properly matters, especially when you are running a sequence of experiments and files.

SQLite makes exit behavior straightforward.

Core Concepts

flowchart LR
A[Working in sqlite3 shell] --> B{Need to leave?}
B -->|Yes| C[Use .quit or Ctrl+D]
C --> D[Return to system shell]
MethodPlatformNotes
.quitAllExplicit and beginner-friendly
.exitAllEquivalent in sqlite3 shell
Ctrl + DmacOS/LinuxSends EOF
Ctrl + Z then EnterWindows cmdEOF behavior in many terminals

Code Examples

-- Preferred explicit exit command.
.quit
Expected output
sqlite> prompt disappears and terminal returns to normal shell prompt.
-- Equivalent exit command.
.exit
Expected output
Same result: sqlite3 shell closes.

SQLite-Specific Nuances

SQLite Nuance

Dot-command exits are shell-level actions. They do not become part of SQL history sent to a database engine.

Common Pitfalls / Best Practices

Pitfall

Typing quit; (without dot) as SQL and expecting the shell to close.

Use .quit or .exit exactly.

Best Practice

Use .quit consistently while learning so your muscle memory is portable across platforms.

Quick Challenge

Open sqlite3 :memory: and exit twice, once with .exit and once with .quit.

View Solution

Both commands close the shell and return you to the system prompt.