The SQLite command-line tool, also known as sqlite3, is a program that allows you to interact with SQLite databases from the command line. It can be used to create, open, close, and manage SQLite databases, as well as to execute SQL queries.
To use the sqlite3 tool, you first need to open a terminal window and navigate to the directory where the sqlite3 program is located. Then, you can use the following syntax to open a connection to an SQLite database:
Code snippet
sqlite3 database_name
For example, to open a connection to a database named my_database.sqlite, you would use the following command:
Code snippet
sqlite3 my_database.sqlite
Once you have opened a connection to a database, you can execute SQL queries by typing them at the prompt. For example, to select all rows from the products table, you would use the following query:
Code snippet
SELECT * FROM products;
The sqlite3 tool also supports a number of other commands, such as CREATE TABLE, INSERT INTO, UPDATE, and DELETE. You can use the help command to see a list of all available commands.
Here are some of the most common commands used with sqlite3:
.help : Shows a list of all available commands.
.tables : Lists all tables in the current database.
.schema table_name : Shows the schema for the specified table.
.exit : Closes the current connection to the database.
The sqlite3 tool is a powerful tool that can be used to manage SQLite databases from the command line. It is a valuable tool for developers and system administrators who need to work with SQLite databases.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
The SQLite command-line tool, also known as sqlite3, is a program that allows you to interact with SQLite databases from the command line. It can be used to create, open, close, and manage SQLite databases, as well as to execute SQL queries.
To use the sqlite3 tool, you first need to open a terminal window and navigate to the directory where the sqlite3 program is located. Then, you can use the following syntax to open a connection to an SQLite database:
Code snippet
For example, to open a connection to a database named my_database.sqlite, you would use the following command:
Code snippet
Once you have opened a connection to a database, you can execute SQL queries by typing them at the prompt. For example, to select all rows from the products table, you would use the following query:
Code snippet
The sqlite3 tool also supports a number of other commands, such as CREATE TABLE, INSERT INTO, UPDATE, and DELETE. You can use the help command to see a list of all available commands.
Here are some of the most common commands used with sqlite3:
The sqlite3 tool is a powerful tool that can be used to manage SQLite databases from the command line. It is a valuable tool for developers and system administrators who need to work with SQLite databases.