Client APIs
Usage
The typical usage of the `duckdb` command is the following:  
```bash
duckdb [OPTIONS] [FILENAME]
```  
#### Options {#docs:api:cli:overview::options}  
The `[OPTIONS]` part encodes [arguments for the CLI client](#docs:api:cli:arguments). Common options include:  
* `-csv`: sets the output mode to CSV
* `-json`: sets the output mode to JSON
* `-readonly`: open the database in read-only mode (see [concurrency in DuckDB](#docs:connect:concurrency::handling-concurrency))  
For a full list of options, see the [command line arguments page](#docs:api:cli:arguments).  
#### In-Memory vs. Persistent Database {#docs:api:cli:overview::in-memory-vs-persistent-database}  
When no `[FILENAME]` argument is provided, the DuckDB CLI will open a temporary [in-memory database](#docs:connect:overview::in-memory-database).
You will see DuckDB's version number, the information on the connection and a prompt starting with a `D`.  
```bash
duckdb
```  
```text
v{{ site.currentduckdbversion }} {{ site.currentduckdbhash }}
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
D
```  
To open or create a [persistent database](#docs:connect:overview::persistent-database), simply include a path as a command line argument:  
```bash
duckdb my_database.duckdb
```  
#### Running SQL Statements in the CLI {#docs:api:cli:overview::running-sql-statements-in-the-cli}  
Once the CLI has been opened, enter a SQL statement followed by a semicolon, then hit enter and it will be executed. Results will be displayed in a table in the terminal. If a semicolon is omitted, hitting enter will allow for multi-line SQL statements to be entered.  
```sql
SELECT 'quack' AS my_column;
```  
| my_column |
|-----------|
| quack     |  
The CLI supports all of DuckDB's rich [SQL syntax](#docs:sql:introduction) including `SELECT`, `CREATE`, and `ALTER` statements.  
#### Editor Features {#docs:api:cli:overview::editor-features}  
The CLI supports [autocompletion](#docs:api:cli:autocomplete), and has sophisticated [editor features](#docs:api:cli:editing) and [syntax highlighting](#docs:api:cli:syntax_highlighting) on certain platforms.  
#### Exiting the CLI {#docs:api:cli:overview::exiting-the-cli}  
To exit the CLI, press `Ctrl`+`D` if your platform supports it. Otherwise, press `Ctrl`+`C` or use the `.exit` command. If used a persistent database, DuckDB will automatically checkpoint (save the latest edits to disk) and close. This will remove the `.wal` file (the [write-ahead log](https://en.wikipedia.org/wiki/Write-ahead_logging)) and consolidate all of your data into the single-file database.  
#### Dot Commands {#docs:api:cli:overview::dot-commands}  
In addition to SQL syntax, special [dot commands](#docs:api:cli:dot_commands) may be entered into the CLI client. To use one of these commands, begin the line with a period (` .`) immediately followed by the name of the command you wish to execute. Additional arguments to the command are entered, space separated, after the command. If an argument must contain a space, either single or double quotes may be used to wrap that parameter. Dot commands must be entered on a single line, and no whitespace may occur before the period. No semicolon is required at the end of the line.  
Frequently-used configurations can be stored in the file `~/.duckdbrc`, which will be loaded when starting the CLI client. See the [Configuring the CLI](#::configuring-the-cli) section below for further information on these options.  
Below, we summarize a few important dot commands. To see all available commands, see the [dot commands page](#docs:api:cli:dot_commands) or use the `.help` command.