SQLite

How SQLite3 shows a list of existing tables

As you probably already know, SQLite is a popular relational database management system for embedded systems. It is open-source and requires minimal configuration or installations. SQLite is incredibly simple but yet so powerful that you can use it in a series of applications.

In this tutorial, we will discuss various ways you can view tables in an SQLite database.

Opening an SQLite Database

Before learning how to show tables in SQLite databases, you need to know how to open a database. For this tutorial, I will use the open-source chinook database available here.

https://github.com/lerocha/chinook-database

Once you download the SQLite version of the database, open it using the command sqlite3 as:

sqlite3 Chinook_Sqlite.sqlite

SQLite Show Tables

To show a table in a database, you need to use the .tables command inside the SQLite shell. For example:

sqlite> .tables
Album          Employee       InvoiceLine    PlaylistTrack
Artist         Genre          MediaType      Track
Customer       Invoice        Playlist

The above command shows all the tables that exist in that database.

List Tables with Pattern

SQLite also allows you to specify a pattern of the tables you would like to show. For example, to list all tables starting with the letter p:

sqlite> .tables "P%"
Playlist       PlaylistTrack

The final method and most straightforward method to view the tables in a database is to use SQLite Browser. Ensure that you have SQLite browser installed. Open the database and click on the tab, Browse Data.

Conclusion

This quick tutorial has illustrated various ways to list tables in a specific database using the SQLite shell and the SQLite Browser tool.

About the author

John Otieno

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list