How to create an SQLite database
To create a database in SQLite, you can follow the steps below:
- Download the installation package for SQLite and install it on your computer.
- Open the terminal or command prompt window, and navigate to the installation directory of SQLite.
- Enter the following command to start the SQLite console:
sqlite3
- the database named mydatabase.
sqlite> .open mydatabase.db
- The database file has been successfully created, so you can now start creating tables and inserting data into it.
For example, you can use the following command to create a table named users and define some columns:
sqlite> CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT,
age INTEGER
);
- Add to
sqlite> INSERT INTO users (name, age) VALUES ('Alice', 25);
sqlite> INSERT INTO users (name, age) VALUES ('Bob', 30);
- Choose
sqlite> SELECT * FROM users;
By following the steps above, you have successfully created an SQLite database, created a table within it, and inserted some data. You can now continue to work with the database according to your needs.