Exploring SQLite special commands

Once you connect to a database, you can use a number of built-in SQLite commands that are known as dot commands and that can be used to obtain information from the database files.

You can obtain the list of special commands by issuing the .help command in the SQLite prompt. These are SQLite-specific commands, and they do not require a semicolon at the end. The most commonly used dot commands include the following:

  • .tables: This lists all of the tables within a database. The following screenshot displays the list of tables found inside the sms.db database:
  • .schema table-name: This displays the SQL CREATE statement that was used to construct the table. The following screenshot displays the schema for the handle table from the sms.db database:
  • .dump table-name: This dumps the entire content of a table into SQL statements. The example in the following screenshot displays the dump of the handle table, which is found inside the sms.db database:
  • .output file-name: This redirects the output to a file on the disk instead of showing it on the screen.
  • .headers on: This displays the column title whenever you issue a SELECT statement.
  • .help: This displays the list of available SQLite dot commands.
  • .exit: This disconnects from the database and exits the SQLite command shell.
  • .mode: This sets the output mode; it could be .csv, HTML, tabs, and so on.
Make sure that there is no space between the SQLite prompt and the dot command; otherwise, the entire command will be ignored.
..................Content has been hidden....................

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