zoukankan      html  css  js  c++  java
  • iOS-数据库sqlite的使用

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

    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 字段 > 内容



  • 相关阅读:
    对vector等STL标准容器的排序操作
    Security log is full,only administrator can log on to fix the problem(安全日志满了)
    Linux vi 中搜索关键字
    Linux tar 解压缩命令
    max_size, capacity and size 的区别
    四个基数任意次数组合相加得到一个数N,求所有可能组合
    robot framework 笔记(三),RF安装
    电脑重装后 python 2 3快速安装
    python练习题(四)
    apscheduler 执行报错No handlers could be found for logger "apscheduler.executors.default
  • 原文地址:https://www.cnblogs.com/mfmdaoyou/p/7351206.html
Copyright © 2011-2022 走看看