SQLite3 installation and basic operations

Source: Internet
Author: User

1. Install SQLite3

  1. 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.

  1. 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.

  1. Sqlite3-version

4. Install graphical interfaces

If you do not like the command line, it is necessary to install it. This item is optional.

  1. Sudo apt-get install sqlitebrowser

5. Install support for other languages

  1. // PHP support
  2. Sudo apt-GetInstall php5-sqlite
  3. // Ruby support
  4. Sudo apt-GetInstall libsqlite3-ruby
  5. // Python support
  6. Sudo apt-GetInstall python-pysqlite2

6. Create a database

You can run the following command in any directory (such as/home/mark/database ):

  1. 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.

  1. 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

  1. Insert into mytable values ('Mark',28);
  2. Insert into mytable values ('Hello',30);

9. query data

  1. Select * from mytable;

Query Result

10. delete a table

  1. 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.

  • 1
  • 2
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.