开发中常用的简单SQL语句

创建表: create table if not exists 表名 (字段名1, 字段名2...);
create table if not exists t_student (id integer primary key autoincrement, name text not null, age integer)

增加数据: insert into 表名 (字段名1, 字段名2, ...) values(字段1的值, 字段2的值, ...);
insert into t_student (name,age) values (@"Jack",@17);

根据条件删除数据: delete from 表名 where 条件;
delete from t_student where name = @"Jack";

删除表中所有的数据: delete from 表名
delete from t_student

根据条件更改某个数据: update 表名 set 字段1 = '值1', 字段2 = '值2' where 字段1 = '字段1的当前值'
update t_student set name = 'lily', age = '16' where name = 'Jack'

根据条件查找: select * from 表名 where 字段1 = '字段1的值'
select * from t_student where age = '16'

查找所有数据: select * from 表名
select * from t_student

删除表: drop table 表名
drop table t_student

排序查找: select * from 表名 order by 字段
select from t_student order by age asc (升序,默认) select from t_student order by age desc (降序)

限制: select * from 表名 limit 值1, 值2
select * from t_student limit 5, 10 (跳过5个,一共取10个数据)

你可能感兴趣的:(开发中常用的简单SQL语句)