Viewing database schema data

SQLite offers several commands as part of a command set to get information about the contents of a database. For example, to get a list of tables, use the .table command. To find a specific table name, use a % symbol and text as a pattern to find the result, for example, .tables [pattern], as shown in the following screenshot. By issuing the .tables command and appending a %te% text to it, is a request to SQLite to list all its tables within the database that has the word te (in our case temp) in their name which are displayed correctly:

Viewing database schema data

Prior to the following example, a temp_idx index has been created, to get a list of indexes for the temp table, at the sqlite3 prompt .indices temp, which is actually the .indices command followed by the table name, as shown here:

Index data

By using the preceding command, the temp table's index can be seen.

To view the schema of the database, the following command can be issued, .schema, but type the .schema <table name> command to get specific information on a name database object. See the following screenshot for more information:

Schema data

The preceding command shows the output from the temp set of tables and index from the database. The next command shows the whole database schema:

Schema data

The SQLite master schema table shows tables and indexes that exist on the SQLite database.