sqlite3数据库,增删改查

     

搜索libsql


  //由于文件读写,归档,NSUserDefault,做持久存储的时候,是一个覆盖的过程,效率太低,更多的时候使用数据库来做持久化存储
        //鉴于手机的硬件配置,使用轻量级的数据库(sqlite)
        //数据库内有更多张表,每个表都有很多字段,这写字段中用于做唯一标识的,被称为主键
    
        //SQL,结构化查询语句,用于对数据进行操作,(,,,)的语句
        //SQL语句不区分大小写
        //1.创建表格
        //create table 表名 (字段名 字段数据类型 是否是主键 是否为空 默认值是多少,...)
        //student表为例(ID,name,age,gender,photo)
        //create table "Student" ("ID" integer primary key n t null, "name" text, "age" integer, "gender" text, "photo" blob)
    
        //2.插入数据
        //insert into 表名 (字段名1,字段名2,字段名2,...) values (1,2, 3,...)
    
        //例如: insert into "Student" (name,gender,age) values ("赵卫东", "", "20")
        //3.删除数据
        //delete from 表名 where 字段名 =
        //例如: delete from "Student" where ID = 6
    
        //4.修改数据
        //update 表名 set 字段名 = where 字段名 =
        //例如 update "Student" set gender = "" where ID = "5"
    
        //5.查询数据
        //select 字段名 from 表名 where 字段名 =
        //例如 select name, age from "Student" where ID = 5
        //例如: select * from Student where name = "小强"
        //例如: select * from Student

//
//  DataBase.h
//  LessonDataBase12-26
//
//  Created by lanouhn on 14/12/26.
//  Copyright (c) 2014 niutiantian. All rights reserved.
//

    //这个类主要对数据库进行管理,(打开,关闭)


#import <Foundation/Foundation.h>
#import <sqlite3.h>

原文地址:https://www.cnblogs.com/tian-sun/p/4311433.html