Command-Line Options

The sqlite3 tool understands the following command-line format:

sqlite3 [options...] [database [SQL_string]]

Options are given first, followed by an optional database filename. This database will be opened as the main database. If the database file does not exist, it will be created. If no database filename is given (or an empty string is given), a file-backed temporary database will be created. If the database name :memory: is given, an in-memory database will be created.

If a database filename is given, an optional SQL string can be provided. This string may consist of one or more SQL statements separated by semicolons. The SQL statements need to be passed as a single argument, so they will most likely need to be enclosed in quotes. If present, sqlite3 will open the database file, execute the provided SQL statements, and exit. Dot-commands cannot be included in the SQL string. If no SQL string is given, sqlite3 will provide an interactive prompt and accept either SQL or dot-commands from the terminal interface.

The interactive startup sequence will attempt to locate and open the .sqliterc init file in the current user’s home directory. If the file exists, lines will be read and executed before any other processing (including the command-line SQL string). The init file may contain both dot-commands and SQL statements. All SQL statements must end in a semicolon. The init file is processed before the command-line options. This allows the command-line options to override any dot-commands that are in the init file.

Recognized command-line options are:

-bail

Turns the bail flag on. Batch files will stop processing if an error is encountered. See the .bail command for more details.

-batch

Forces batch-style I/O. This will suppress things like the welcome banner and command prompts.

-column

Sets the output mode to column. See the .mode command for more details

-csv

Sets the output mode to csv. See the .mode command for more details.

-echo

Turns echo mode on. See the .echo command for more details.

-header -noheader

Turns headers on or off. See the .headers command for more details.

-init filename

If this is an interactive session, use this file as an init file rather than the .sqliterc file.

-interactive

Forces interactive style I/O. This includes things like the welcome banner and command prompts.

-help

Displays a summary of the command-line options and exits.

-html

Sets the output mode to html. See the .mode command for more details.

-line

Sets the output mode to line. See the .mode command for more details.

-list

Sets the output mode to list. See the .mode command for more details.

-nullvalue string

Sets the NULL display string. See the .nullvalue command for more details.

-separator string

Sets the separator string. See the .separator command for more details.

-version

Prints the SQLite version and exits.

Options will also be recognized if they are prefaced with two dashes, rather than just one.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.211.66