SQLite entry notes 1

Source: Internet
Author: User

Because glusterfs is implemented for multiple users, user registration and login are required, and user registration involves databases. Therefore, SQLite is used. Why choose it?

1. Small

2. cross-platform

3. configuration-free. Like access, you only need to upload database files to the server over FTP. No additional server support is required.

4. Easy backup. Because it is only a file, you only need to copy the file to back up the entire database.

5. Although it is a lightweight database, it supports a single database file up to 2 TB.

6. Fast and unparalleled. In actual tests, the insert and query speed of SQLite is not lower or lower than that of MySQL in the case of millions of records, which is faster than that of SQL Server, 10 times higher than access (but this does not mean it can replace SQL Server)

7. my application just saves the user registration information. It may only need one table record, and it does not need complicated SQL operations, such as join table queries or transaction operations, the smaller the database, the better.

SQLite is a lightweight database and an acid-compliant associated database management system. It is designed to be embedded and has been used in many embedded products, it occupies very low resources. In embedded devices, it may only need several hundred KB of memory. SQLite is a small C library for implementing the embedded SQL database engine. It implements an independent, embedded, and zero-configuration SQL database engine. It supports mainstream operating systems such as Windows, Linux, and UNIX, and can be combined with many programming languages, such as TCL, C #, PHP, Java, and ODBC interfaces, similar to MySQL and PostgreSQL, the two world-renowned open-source database management systems, the processing speed is faster than that of them.

The biggest feature of SQLite is that its data type is typelessness ). This means that data of any type can be saved to any column of any table to be saved, regardless of the Data Type declared by this column. Although the data type of each field needs to be declared when the table structure is generated, SQLite does not perform any checks. Developers rely on their own programs to control the types of input and read data. An exception is that when the primary key is an integer value, an exception occurs if a non-integer value is to be inserted.

Although SQLite allows data types to be ignored, we recommend that you specify the data type in the create table statement, because the data type facilitates program readability and facilitates communication with other programmers. In addition, although data types are not differentiated during data insertion or reading, different data types are different during comparison.

For details, go to Baidu encyclopedia's introduction to SQLite or the official website.

1. first go to the official website (http://www.sqlite.org/) to download the software (Windows version, all the tests below are in the Windows environment), unzip it, no installation required
2. Switch to the decompressed directory under cmd, such as cd d: \ SQLite
3. enter sqlite3 test in the command line. DB, which generates test in the current directory. DB database. Of course, the following absolute path can also be created in other paths. The version prompt is displayed, indicating that the database is successfully created.
4. The databases command displays the created database. You can use. Help to view which commands can be called.
5. create Table user (ID int, uname varchar (10); // create a table. Note that all commands except SQLite must end with a semicolon, otherwise, it will wait until the first semicolon appears to judge the end of the command.
6. Tables: displays the table name.
7. insert into user values (1, 'Hello ');
Insert into user values (2, 'test'); // insert data
8. Select * from user; // query data
Select * from user where id = 2;

You can set the display format of the query result to the display format after common database queries. Enter the format at the SQLite terminal prompt. mode column command, and then display the header,. headers on command, as shown in. help or official documentation instructions, the general addition, deletion, modification, and query operations are simple SQL statements

9. update user set uname = 'hehe' where uname = 'test'; // update

10. Delete from user where id = 1; // Delete

Install sqlitedirectly from the sqlite-shell-linux-x86-3070701.zip package under ubuntu., switch to the decompressed directory, and use sqlite3 test. database creation, no response, also prompted that not installed, need to use sudo apt-Get install sqlite3 to install, why not like the DOS operation in windows, directly use the executable sqlite3 command to go to The SQLite console? Reading the instructions on getting started on the official website, the operations are the same on Linux and Windows dos terminals. There is no distinction between them. If you know something, please advise.

After using sudo apt-Get install sqlite3 in Ubuntu, you can directly use the command sqlite3 to create a database, then create a table and operate a table, and test the database created through SQLite in windows. DB, which can be copied directly to Ubuntu to verify the cross-platform compatibility of SQLite, facilitating the porting of features.

References:

1. http://www.sqlite.org/sqlite.html

2. http://baike.baidu.com/view/19310.htm

3. http://blog.163.com/alpsdyk2001@126/blog/static/5279414820100425443999/

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.