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 to retrieve data from a specific year?
- How do I use UUIDs in SQLite?
- How do I show the databases in SQLite?
- How can I use an upsert statement to update data in a SQLite database?
- How do I use the SQLite ZIP VFS to compress a database?
- How do I download and install SQLite zip?
- How can SQLite and ZFS be used together for software development?
- How can I query a SQLite database for records from yesterday's date?
- How do I use the SQLite SUBSTRING function?
- How do I use the SQLite zfill function?
See more codes...