We will provide step-by-step directions on how to display databases in SQLite command to help you through the process.
How to Show Databases in SQLite Command
To begin using SQLite, open your system’s command prompt and enter the following command to open SQLite interpreter:
To follow along with the examples in this guide, we will assume that you are executing all commands in the C:\sqlite\db path. However, feel free to choose your own path on your system.
To create an SQLite database named linux.db, execute the following command:
Note: The above command for creating a database is optional and is only necessary if you haven’t already created a database using the SQLite command.
To display all the databases of the current connection, run the following SQLite command:
This will show a list of all the databases attached to the current connection.
In the above screenshot, there is only one database linux.db in the path C:\sqlite\db. If you have multiple databases connected, they will be displayed here.
If you have created multiple databases and the above command does not list them, use the “attach database” command to add them to the current connection. This command connects to a new database and makes its tables available for use in SQL queries.
In the below-given command, I am creating a new database named linux2 in the same connection linux.db:
You can add multiple databases using the above-given command:
Once the connection is established between these databases you can run the .databases command again to show the databases in SQLite:
Bottom Line
The sqlite3 is the command line tool for interacting with the SQLite databases. When using the command line tool, you can use the .databases command to show the connected databases. This command will return the list of databases with their location in the system.