SQLite Basics What is SQLite
- SQLite is a lightweight, embedded database
- It occupies very low resources, in the embedded device, may only need hundreds of K of memory is enough
- Its processing speed is faster than the two famous databases of MySQL and PostgreSQL.
SQLite是无类型的
What is a database
A database is a warehouse that organizes, stores, and manages data in accordance with its data structure.
The database can be divided into 2 major categories
- relational database (Mainstream)
- Object Type Database
Common relational database
- PC-side: Oracle, MySQL, SQL Server, Access, DB2, Sybase
- Embedded \ Mobile Client: SQLite
Characteristics of relational database
- Accessing Data in tabular form
- Each row represents a complete record
- Establish a "relationship" between a foreign key and another data table
- Enables easy data maintenance
- Storage space can save
- You can split a data and maintain them!
* Oracle, SQL Server, MySQL...服务端使用的数据库,需要安装,需要独立的机器,需要单独配置* SQLite 零成本,就是一个文件,存储着需要的数据* MAC 中内置了 SQLite,什么都不需要,就可以直接使用!
SQLite in iOS development
- The database file is a separate file, in actual development, the database file is usually saved in the sandbox document/cache directory
- In the program development, it is necessary to operate the database file through the T_sql language!
Types of SQL statements
Data definition statements (ddl:data definition Language)
- Includes operations such as Create and drop
- Create a new table or delete a table in the database (CREATE table or drop tables)
Data manipulation statements (Dml:data manipulation Language)
- Include INSERT, update, delete, and more
- The above 3 actions are used to add, modify, and delete data in a table, respectively
Data query Statement (dql:data query Language)
- can be used to query for data in a table
- Keyword SELECT is the most used operation for DQL (and all SQL)
- Other dql commonly used keywords are where,order by,group by and having
Getting Started with SQLite