iOS中数据库-建立表-增删改查数据-基础语法

什么是SQL:结构化查询语言。create建立表drop删除表,delete是删除表中的数据
sql

SQL语句不区分大小写,每条语句必须以分号结束,数据库中不可使用关键字用为表名(sql经常使用关键字  select create from。。。。。)数据库

创表格式:字符串

create table if not exists 表名(字段1 字段类型1,字段2 字段类型2,.......);table

也能够建表时候不声明类型:如:create table t_student(name,age);最好是写类型
date

例如:create table if not exists 表名 (字段1 字段类型1,字段2 字段类型2,.......);select

        create table if not exists 表名 (id integer,name text,age integer);数据

删除表:drop table if exists 表名;如:drop table if exists t_student;
查询

表中插入数据格式:tab

insert into 表名(字段类型1,字段类型2,........)values(字段1的值,字段2的值,......)语言

例如:insert into t_student(name,age)values('tom',10);数据库中的字符串内容要用单引号括住

网表里面插入数据,能够不用每项都插入值。

删除数据格式:delete from 表名;如:delete from t_stu;

更新数据格式:update 表名 set 字段1=字段1的值,字段2=字段2的值,....;

如:update s_stu set age=10,sex='nan';这句话会把表中的全部age改成10,全部sex改成nan.

查询表数据:select *from 表名;//查询全部字段

select *from t_stu where age>10;//条件查询

相关文章
相关标签/搜索