Sqlite   发布时间:2022-05-22  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Sqlite简单例子大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
-- 1、创建数据库 -- 2、创建表 create table employee( _ID integer primary key autoINCREMENT,name text,age integer,money integer ); -- 删除表 DROP table 表名称 drop table employee; -- 3、插入数据 -- INSERT INTO 表名称 VALUES (值1,值2,....) insert into employee values (1,'赵日天',28,10000); insert into employee values (2,'叶良辰',18,3000); insert into employee values (3,'龙傲天',15000); insert into employee values (4,'福尔康',48,11000); insert into employee (name,age,money) values ('赵日天',10000); insert into employee (name,money) values ('叶良辰',3000); insert into employee (name,money) values ('龙傲天',15000); insert into employee (name,money) values ('福尔康',11000); -- INSERT INTO table_name (列1,列2,...) VALUES (值1,....) insert into employee (name,money) values ('刘斩仙',38,8000) -- 4、删除数据 -- DELETE FROM 表名称 WHERE 列名称 = 值 -- 删除一行数据 where表示条件 delete from employee where name='刘斩仙'; --删除所有数据 DELETE FROM employee -- 5、修改数据 --UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值 -- 修改一行数据 把龙傲天改成38岁 update employee set age=38 where _ID=3 --把龙傲天年龄加10岁 update employee set age=age+10 where _ID=3 -- 修改多行数据 把龙傲天年龄加10岁,工资涨10000 update employee set age=age+10,money=money+10000 where _ID=3 -- 修改所有数据 update employee set money=10000; -- 把赵日天和龙傲天的工资都改成20000 update employee set money=20000 where _ID=1 or _ID=3; -- 6、查询数据 -- SELECT 列名称 FROM 表名称 -- 只要name,money select name,money from employee; -- SELECT * FROM 表名称 *代表所有列 select * from employee; -- 只查询一行数据 select * from employee where _ID=4; -- 7、修改表的结构 -- 向表中添加一列 ALTER table table_name ADD column_name datatype alter table employee add card text; -- 8、分页 select image,Title,content from employee limit 0,5; (0这个位置的意思是从哪个位置开始也称偏移量,5这个位置是查询多少条数量) -- 9、查询总共有多少行,返回的是所有列的行数最多的值(无论有几列或者有可能某一列是没有数据或者为空) select count(*) from employee; -- 10、查询某一列(元素)有多少行,在一个表格中假如有15行,但是这个列中有某一行是null,那么得到的值就是14 select count(image) from emplyee;

大佬总结

以上是大佬教程为你收集整理的Sqlite简单例子全部内容,希望文章能够帮你解决Sqlite简单例子所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: