iOS Development Database Fmdb 1. Introduction
Requirements: If you need to save a large amount of complex data, use a database, such as a compliance test project
Commonly used databases:
(1) Microsoft SQL Server 2000/2008, SMB uses more
(2) Oracle is more complex and large enterprises use more
(3) MySQL database, web site use more
(4) SQLite: Local database, access to data fast enough, direct access to files
Simple enough, the functionality is not particularly complete with respect to other database software, enough
Small enough that the system does not exceed 1M and is suitable for use on the mobile side
2. MesasqliteUse
Example: Using a data store to store information about a class student
Learning number SID user name username password Password Score score
1501 Zhangsan 123 100
1502 Lilei 321 90
1503 WANGWU 222 80
(1) Create a database
(2) Creating a data table
(3) Design data table (add multiple fields/columns)
(4) Common operation of database
increase, delete, change, check
3. SQL Structured query statements
SQL, Structure query Language, Structured Query Language, the role of the operation of the database (create table, data additions and deletions)
(1) Creating a data table
Create Table integer varchar (20 varchar ))
Create Table if not exists integer varchar (the varchar ( ))
(2) Inserting data
Insert into Values (1503,'wangwu','222',' ')
(3) Query data
<1> querying all data in a table
Select * from Studentinfo;
<2> Querying the specified fields
Example: query all names username
Select from Studentinfo
<3> query based on specified criteria
Example: Find all information for name Zhansan
Select * from where username='zhangsan'
<4> query based on multiple criteria
Example: Finding the Uname for zHansan, and all the information about sex for boy
Select * from where username='zhangsan' and password=' 123'
<5> need to sort after query
//in ascending order according to age
Select * from Order by Score
Select * from Order by desc
<6> get rows of data
Select Count (* from Studentinfo
(4) Modify the data
Update Set score='+' where username= ' Zhangsan ';
(5) Delete data
Delete from where sid='1503'
4. FMDB Operation Database
(1) configuration
Import files,
Add a binary library libsqlite3.dylib,
Contains the header file #import "FMDatabase.h"
5. DatabaseUse in Projects-single case design mode
iOS Development Database Fmdb