SQLite installation and use
Install SQLite
1. Visit the official website of SQLite: https://www.sqlite.org/index.html
2. On the Downloads page, select the pre compiled binary file that is suitable for your operating system.
3. Download and extract the file. On Windows systems, after decompression, you will see a sqlite3. exe executable file.
4. Add the directory where the sqlite3. exe file is located to the system environment variable.
5. Enter the "sqlite3" command in the command line window, and if you see the version information of SQLite, it indicates that the installation was successful.
Create Data Table
1. Open a command line window and enter the "sqlite3" command to enter the SQLite console.
2. Execute the following command to create a data table named "users" and define two fields "id" and "name":
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT
);
3. Execute the following command to view the created data table:
.tables
This will list all created data tables.
Data insertion
1. Execute the following command to insert a piece of data into the "users" table:
INSERT INTO users (id, name) VALUES (1, 'John');
Data modification
1. Execute the following command to update a piece of data to the "users" table:
UPDATE users SET name = 'Peter' WHERE id = 1;
Data Query
1. Execute the following command to query all data in the "users" table:
SELECT * FROM users;
Data deletion
1. Execute the following command to delete a piece of data from the "users" table:
DELETE FROM users WHERE id = 1;
Precautions:
-SQLite is an embedded database without a separate server process, so there is no need to start or stop database services. You can directly integrate SQLite databases into your application.
-SQLite's file storage will occupy your hard drive space, ensuring that you regularly backup and clean up database files as needed.
-If using SQLite on a Windows system, you can also use the Graphical User Interface (SQLiteStudio, DB Browser for SQLite) to visualize database operations.