[iOS 使用sqllite3.0] 创建表 , 增/删/查/改 常用命令语句

来源:互联网 发布:网络直销公司排名 编辑:程序博客网 时间:2024/06/06 15:50

如表结构

表名:usersconfig

表的列名(字段) uid userName active sToken credit_fp lets

一条数据的组成,由 表的列名(字段) = 值 组成

如下 称为一条数据

{表的列名1(字段1) = 值,表的列名2(字段2) = 值,表的列名3(字段3) = 值,表的列名4(字段4) = 值,表的列名5(字段5) = 值}

创建表的命令语句为

@"create table if not exists usersconfig(ID INTEGER PRIMARY KEY AUTOINCREMENT,uid verchar(20) not null,userName verchar(20) not null,active int not null,sToken verchar(50) not null,credit_fp verchar(50),lets text not null)" 

对应的增删查改

方法列如下

--数据库的建立create table team( -- 创建名字为team的table  stu_id integer primary key autoincrement,   stu_name varchar(100),   stu_password varchar(100),   stu_login varchar(100) )--添加信息 insert into team(stu_name,stu_password,stu_login) values('xiaming','123456','xm') insert into team(stu_name,stu_password,stu_login) values('zhangsan','123456',' zs') --查询信息select *from team --删除信息delete from team where stu_id=3

对应的 usersconfig 表 操作命令如下

查列表数量 (根据 uid 字段 查询表中数据条数)

@"select count(*) from usersconfig where uid = '%@'"

更新数据

@"update usersconfig set active = '%@', sToken = '%@', credit_fp = '%@'  where uid = '%@'"

插入数据(表的列名对应,插入一条数据)

@"insert into usersconfig (uid, userName, active, sToken, credit_fp, lets) values ('%@', '%@', '%@', '%@', '%@', '%@')"

删除数据 (根据userName 字段 删除一条数据)

@"delete from usersconfig where userName = '%@'"
0 0
原创粉丝点击