SQL 的简单命令(增删改查)
2016-11-28 11:14
330 查看
数据库操作的资料: 链接: https://pan.baidu.com/s/1dFl3q6X 密码: nvy7 -- 增:insert into 表名 (列名) values (值) insert into Test (id,name) values (7,'dew') -- 删:表名 where 列名=值 delete Test where id=3 -- 查:select 列名 from 表名 where 列名=值 select id from Test -- 查询所有信息:select * from 表名 select * from Test -- 使用别名查询之一:select 列名 as 别名 from 表名 select id as ab from Test -- 使用别名查询之二:select 表的别名.列名 as 列的别名 from 表名 表的别名 select a.name as goodName from Test a -- 区间查询:select * from 表名 where 列名 Between 值 and 值 select * from Test where id Between 3 and 5 -- 指定查询:select * from 表名 where 列名 in(指定的值,指定的值,指定的值) select * from Test where id in(3,5,6) -- 模糊查询:select * from 表名 where 列名 like 含有的字符(_代表一个占位符,%表示任意字符) select * from Test where name like '_a%' -- 去重复查询:select distinct 列名,列名 from 表名 select distinct id ,name from Test -- 降序:select * from 表名 order by 列名 desc select * from Test order by id desc -- 升序:select * from 表名 order by 列名 asc select * from Test order by id asc -- 改:update 表名 set 列名=新值 where 列名=值 update Test set id=5 where id=2 -- 拼接用||(比较少用) select 'id'|| 'name' from Test
-- 查找两个表中ID相等的
select a.id, a.name,b.math from stu a,scores b where a.id = b.id
-- 右外连接
select b.id, a.name,b.math from stu a,scores b where a.id(+) = b.id
select b.id, a.name,b.math from stu a right outer join scores b on a.id = b.id
-- 左外连接
select a.id, a.name,b.math from stu a,scores b where a.id = b.id(+)
select a.id, a.name,b.math from stu a left outer join scores b on a.id = b.id
-- 满外连接
select a.id,b.id, a.name,b.math from stu a full outer join scores b on a.id = b.id
-- 最大值
select max(scores.math) from scores
-- 最小值
select min(scores.math) from scores
-- 平均值
select avg(scores.math) from scores
-- 和
select sum(scores.math) from scores
-- 列数
select count(scores.math) from scores
-- 标准差
select stddev(scores.math) from scores
-- 分组函数
select math from scores group by math
相关文章推荐
- 2、mongodb简单的增删改查命令
- Python3连接Mysql(增删改查操作及简单的SQL指令)
- linq to sql 简单的增删改查例子。
- plsql最简单的增删改查命令
- SQL语句的增删改查(详细)
- DB2简单的命令:建表、增删改查
- MYSQL的常用命令和增删改查语句和数据类型
- Linq to SQL 简单增删改查
- 简单的linq to sql 的例子 ,实现了增删改查。
- 黑马程序员---SQL语句(主要是增删改查)
- [轉]MYSQL的常用命令和增删改查语句和数据类型
- 利用反射+自定义特性实现简单ORM(二),“无SQL”的数据库增删改查
- NDatabase 入门,简单使用 增删改查。让NDatabase带你脱离ADO.net,各种SQL 语句,各种DBMS,各种CRM,IOC之类的烦恼。我们也不需要仓库设计模式了,你妹的。不要表了,不要设计数据库字段了。就这样!
- Oracle基础知识-SQL简单命令
- Oracle基础知识-SQL简单命令
- sqlite3 --sql命令简单介绍
- SQL相关增删改查语句
- SQL语句(增删改查)
- MYSQL的常用命令和增删改查语句和数据类型
- C#连接oracle数据库执行简单的增删改查操作