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

如表结构

表名: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 = '%@'"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值