数据库的增删改查和使用流程
2014-07-07 13:21
344 查看
创建表 列名 类型,
1...create table Student (id integer , name text, sex text, age integer)
2…create table if not exists Student (id integer , name text default '张三' , sex text not null, age integer)
删除表 表名
drop table Student
插入
全部列插入 表名 值
insert into Student values (1, ‘张三’, ’男’, 18)
部分列插入
insert into Student (name, sex) values ( 'lisi', 'nv')
主键 (唯一, 不能重复)
create table Student (id integer primary key,name text, age integer, sex text )
查询
所有数据
select * from Student
查询姓名这一列 / 两列
select name from Student
select name, sex from Student
条件查询
select * from Student where age > 10
select * from Student where age > 10 and sex = 'nv'
select * from Student where age between 15 and 20
升序/降序
select * from Student order by id sac / desc
只要前 5 条
select * from Student order by id asc limit 5
修改
1列
update Student set age = 18 where sex = ‘男’
多列(勿忘逗号分隔)
update Student set age = 16 , sex = '男' where age < 19
删除
数据
delete from Student where sex = ‘男'
全部
delete from Student
使用sqlite
1.打开数据库
2.执行sql,做出数据处理
3.关闭数据库
操作
1.打开数据库
2.创建一个数据操作指针 stmt
3.执行sql 语句
4.处理结果
1...create table Student (id integer , name text, sex text, age integer)
2…create table if not exists Student (id integer , name text default '张三' , sex text not null, age integer)
删除表 表名
drop table Student
插入
全部列插入 表名 值
insert into Student values (1, ‘张三’, ’男’, 18)
部分列插入
insert into Student (name, sex) values ( 'lisi', 'nv')
主键 (唯一, 不能重复)
create table Student (id integer primary key,name text, age integer, sex text )
查询
所有数据
select * from Student
查询姓名这一列 / 两列
select name from Student
select name, sex from Student
条件查询
select * from Student where age > 10
select * from Student where age > 10 and sex = 'nv'
select * from Student where age between 15 and 20
升序/降序
select * from Student order by id sac / desc
只要前 5 条
select * from Student order by id asc limit 5
修改
1列
update Student set age = 18 where sex = ‘男’
多列(勿忘逗号分隔)
update Student set age = 16 , sex = '男' where age < 19
删除
数据
delete from Student where sex = ‘男'
全部
delete from Student
使用sqlite
1.打开数据库
2.执行sql,做出数据处理
3.关闭数据库
操作
1.打开数据库
2.创建一个数据操作指针 stmt
3.执行sql 语句
4.处理结果
相关文章推荐
- 数据库的增删改查和使用流程
- 分享一段ios中使用数据库的代码(创建,升级,增删改查)
- Android(java)学习笔记193:利用谷歌API对数据库增删改查(推荐使用)
- 使用LitePal插件操作数据库(增删改查)讲解与实例
- PHP程序中使用PDO对象实现对数据库的增删改查操作(PHP+smarty)
- 使用PHP连接数据库_实现用户数据的增删改查的整体操作示例
- 1.3、索引库使用的增删改查,以及数据库的连接导入
- MySQL数据库学习笔记(十二)----开源工具DbUtils的使用(数据库的增删改查)
- 使用MyBatis框架进行数据库的增删改查操作
- 开源工具DbUtils的使用(数据库的增删改查)
- PHP程序中使用PDO对象实现对数据库的增删改查操作的示例代码
- C#2005中使用控件DataGridView实现对数据库增删改查操作
- 数据库中的增删改查、以及sql语句在android中的使用注意事项、保存头像到本地方法
- MySQL数据库学习笔记(十二)----开源工具DbUtils的使用(数据库的增删改查)
- 使用存储过程操作数据库(实现增删改查)
- 使用Spring框架下的JdbcTemplate 完成对数据库的增删改查操作
- robot framework 对使用增删改查对数据库进行操作
- MySQL数据库学习笔记(十二)----开源工具DbUtils的使用(数据库的增删改查)
- 开源工具DbUtils的使用(数据库的增删改查)
- PHP程序中使用PDO对象实现对数据库的增删改查操作的示例代码