sqlite数据库语句

数据库语句

·DDL语句(创建表和删除表)create和drop
//创建表的sql语句
//字段ID代表主键(唯一),字段name等等,字段名后面跟类型(除开主键类型其实可以不写)
create table if not exists t_student(ID integer primary key autoincrement ,name text,age integer,Photo blob)
//删除表的sql语句
drop table if exists t_student
·DML语句(增、删、改)
//增加
insert into t_student(name,age) values (‘xiaoming’, 20)
//更新
update t_student set name = ‘xiaoze’ where age = 20
//删除
delete from t_student
·DQL语句(查询)
//查询表中所有
select * from t_student
//查询结果排序order by(默认升序) desc:降序
select * from t_student order by age desc
//查询表中某些内容
select name,age from t_student
//查询并取别名
select t.name newName,t.age NewAge from t_student t
//模糊查询, %代表任意字符
select * from t_student where name like '%'
//多表查询
select s.name,s.age ,c.className from t_student s, t_class c where s.class = c.class
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容