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 can SQLite and ZFS be used together for software development?
- How do I use the SQLite ZIP VFS to compress a database?
- How can I use SQLite with Zabbix?
- How do I extract the year from a datetime value in SQLite?
- How do I use SQLite xfilter to filter data?
- How do I use the SQLite zfill function?
- How to configure SQLite with XAMPP on Windows?
- How do I call sqlitepcl.raw.setprovider() when using SQLite?
- How can I write SQLite queries?
- How do I generate a UUID in SQLite?
See more codes...