数据库操作的资料: 链接: 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
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/bian-cheng-ri-ji/42701.html