1. Install SQLite3
- Sudo apt-get install sqlite3
2. Install the Toolkit required for Sqlite3 Compilation
Install the Toolkit if necessary. It is just for the sake of experience. You can skip the installation. This item is optional.
- Apt-get install libsqlite3-dev
3. Check whether the installation is successful.
Run the following command to display the sqlite version, for example, 3.6.22.
- Sqlite3-version
4. Install graphical interfaces
If you do not like the command line, it is necessary to install it. This item is optional.
- Sudo apt-get install sqlitebrowser
5. Install support for other languages
- // PHP support
- Sudo apt-GetInstall php5-sqlite
- // Ruby support
- Sudo apt-GetInstall libsqlite3-ruby
- // Python support
- Sudo apt-GetInstall python-pysqlite2
6. Create a database
You can run the following command in any directory (such as/home/mark/database ):
- Sqlite3 test. db
Note: After the command is executed, if test. db is not found in the current directory, the file will be created. if it already exists, the database file will be used directly.
Use. database to view the created database
7. Create a table
For the data type, see the official documentation.
- Create table mytable (name varchar (10), Age smallint );
Similarly, you can use. table to view the mytable created by yourself.
8. insert data into the table
- Insert into mytable values ('Mark',28);
- Insert into mytable values ('Hello',30);
9. query data
- Select * from mytable;
Query Result
10. delete a table
- Drop table mytable;
11. delete a database
Unfortunately, SQLite cannot delete database files like other databases, that isThe drop database test is invalid, but we can delete the database file just like deleting the file, and delete the test. db file under/home/mark/DATABASE.