zoukankan      html  css  js  c++  java
  • SQL 的简单命令(增删改查)

    数据库操作的资料: 链接: 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

  • 相关阅读:
    在CSS中,让页面里的字体变清晰,变细
    前端路由优缺点
    HBuilder和HBuilderX有什么区别?
    HTML5有哪些新特性,移除了那些元素?如何处理HTML5新标签的浏览器兼容问题?如何区分HTML和HTML5?
    js中判断奇数或偶数
    遍历数组的方法
    数组的方法
    免费搜索引擎提交(登录)入口大全
    Vue.js详解
    简述JavaScript模块化编程(二)
  • 原文地址:https://www.cnblogs.com/lantu1989/p/6108711.html
Copyright © 2011-2022 走看看