首页 > 移动平台 > 详细

iOS-数据库sqlite的使用

时间:2017-08-12 19:35:10      阅读:271      评论:0      收藏:0      [点我收藏+]

.数据库的增删查改的方法

sqlite3_exec(db, [sql UTF8String], NULL, NULL, &erro);

数据库的使用

       步骤:01.导入框架<sqlite3.h>

        02.创建数据库(sqlite3_exec)并打开数据库(sqlite3_open())

        03.创建表,加入字段(sqlite3_exec)

                04.实现数据库的增,删,改,查询操作(sqlite3_exec)

05.关闭数据库(sqlite3_close())

        查询操作步骤:

                  01.校验语句是否合法:sqlite3_prepare_v2

                  02.绑定要查询的数据:sqlite3_bind_text

                  03.循环查找内容(依据行):sqlite3_step

                   04.取出这一行里面的数据(依据相应的类):sqlite3_column_text

.SQL语句使用的公式

    建表:

        01. creat table 表名(字段名 字段类型,字段名 字段类型)

        02. creat table if not exist 表名(字段名 字段类型,字段名 字段类型)

        列如:creat table if not exist userid integername textphone text);

    插入:insert into 表名(字段,字段)values 内容内容);

    删除:delete from 表名 where 字段 = ‘要删的内容

    改动:update 表名 set 字段 = ‘改动的内容‘ where 字段 = ‘改动前的内容

    set后面是新的数据,where后面是之前的数据

    查询:

        01.select *from 表名 查询全部的字段(*表示全部)。

        02.select 字段1。字段2....from 表名;

        如:select *from user

 

 

    条件语句:

    where 字段 = 内容;

    where 字段 is 内容;//相当=

    where 字段 = 内容。

    where 字段 is not 内容;

    where 字段 > 内容;

    where 字段 > 内容 and 字段>内容;&& where 字段 > 内容 or 字段 > 内容



iOS-数据库sqlite的使用

原文:http://www.cnblogs.com/mfmdaoyou/p/7351206.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!