sqliteHow do I create a SQLite database?
-
Create a new file with the
.dbextension. This will be the SQLite database file. -
Connect to the database using the
sqlite3command. 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.dbin your application.
Helpful links
More of Sqlite
- How do I troubleshoot a near syntax error when using SQLite?
- How can SQLite and ZFS be used together for software development?
- How do I use SQLite keywords to query a database?
- How do I use the SQLite ZIP VFS to compress a database?
- How do I call sqlitepcl.raw.setprovider() when using SQLite?
- How to configure SQLite with XAMPP on Windows?
- How do I use SQLite with Visual Studio?
- How do I use SQLite transactions?
- How do I write a SQLite query?
- How do I resolve an error "no such column" when using SQLite?
See more codes...