sqliteHow do I create a SQLite database?
-
Create a new file with the
.db
extension. This will be the SQLite database file. -
Connect to the database using the
sqlite3
command. For example:
sqlite3 mydatabase.db
- Create the tables you need in the database. For example:
CREATE TABLE customers (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
address TEXT
);
- Insert data into the tables. For example:
INSERT INTO customers (name, address) VALUES ('John', '123 Main Street');
- Run queries to retrieve data from the database. For example:
SELECT * FROM customers;
Output example
id name address
1 John 123 Main Street
- Close the connection to the database. For example:
.exit
- You can now use the SQLite database file
mydatabase.db
in your application.
Helpful links
More of Sqlite
- How do I use SQLite UNION to combine multiple SELECT queries?
- How do I use the SQLite ZIP VFS to compress a database?
- How do I extract the year from a datetime value in SQLite?
- How can I use SQLite to query for records between two specific dates?
- How can I use SQLite with Github?
- How do I use SQLite to retrieve data from a specific year?
- How to configure SQLite with XAMPP on Windows?
- How can I use SQLite with Maui?
- How do I use SQLite with Visual Studio?
- How do I use the SQLite VARCHAR data type?
See more codes...