天天瞎忙活,QQ:705719110,欢迎来撩!

iOS中常用的SQL语句

iOS开发 随风 215℃ 0评论

常用的SQL语句

1,创建表
CREATE 创建
TABLE 表
PRIMARY KEY主键
AUTOINCREMENT自动增长
NOT NULL 非空
UNIQUE 唯一的

CREATE TABLE Teacher1 (teacher_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, teacher_name TEXT,teacher_sex BOOLEAN)

CREATE TABLE Teacher2 (teacher_id INTEGER PRIMARY KEY AUTOINCREMENT, teacher_name TEXT,teacher_sex BOOLEAN)

2, 删除表
DROP 丢弃 扔到

DROP TABLE Teacher1

3,给表添加列
ALTER 改变 修改

ALTER TABLE Teacher2 ADD teacher_age INTEGER

4,插入数据

INSERT INTO Teacher VALUES(1,’zhangsan’,1)
INSERT INTO Students (name,sex)VALUES(‘zhangsan’,0)

5,查询数据
SELECT 查询
* 全部
FROM

SELECT * FROM Students
SELECT * FROM Students WHERE number<10 SELECT * FROM Students WHERE number<10 OR sex=1 SELECT * FROM Students WHERE number<10 AND number>5

like 匹配
SELECT * FROM Students WHERE name like ‘zhang%’
SELECT * FROM Students WHERE name like ‘zhang_’

LIMIT 限制
从第六条开始 往后的15条
SELECT * FROM Students LIMIT 5,15

6,修改数据
UPDATE 更新
set 设置

UPDATE Students set name=’lisi’,sex=1 where number < 10 AND number>5

7,删除数据
DELETE 删除

DELETE FROM Students WHERE number > 25

转载请注明:怼码人生 » iOS中常用的SQL语句

喜欢 (0)
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址