zoukankan      html  css  js  c++  java
  • 2016/05/09(数据库)

    DML:

    向表中加SQL数据的语句是INSERT

    insert into <表名>(列名) values(值列表) /增加相应列的属性

    在数据库中mull和空数值不一样

    insert into 表名(列名) select 到表的列 from 到表的名 /复制数据

    update 表名 set 列A=新列A where 过滤条件 /更改已有数据

    如果想将数据删除只需把值该为null

    忽略where将会改变表中的列A 所有的值

    delete from 表名 where 过滤条件  /删除一行数据或者多行

    truncate table 表名 /直接删除所有的数据  而且不能恢复

     简单的数据查询(DQL)

    在MYSQL 中所有的值和null相加都是null

    投影操作:select 列A from 表名

    表前缀名:select  p.name from 表名 as p

    列别名:select 列A as A from 表名 as T

    分页处理:

         select 列A from 表名 limit 开始序号,返回需要显示的多少行

         limit在mysql中代表从什么地方开始显示固定的行数

    排出重复的数据:select distinct 列A from 表名

    选择操作:

            select 列名 from 表名 where 条件 (单一条件)

            select 列A,列B from 表名 where 条件A and 条件B (多条件)

    计算列:

            select 列A +列B  from 表名

    选择操作:

           select * from 表名 where 列A=100 当列A=100为真的时候才执行

    模糊查询(LIKE):

           select * from 表名 where 列A like '条件'

           %表示通配符(包含零个或多个字符)

           _ 表示只能通配单个字符

    在数据库中查询值是否为null 不能=null 而是使用 is null 或者 is not null

    排序操作(ORDER BY):

       select * from 表名 order by 列A  /以列A 升序排序

       select * from 表名 order by 列A desc /以列A 降序排序

  • 相关阅读:
    杂记-2
    2019CSP-S游记
    csp2020
    特征根法小记
    csp模拟赛低级错误及反思
    备份
    黑科技——树剖两次dfs转一次dfs!
    输出天干地支
    蓝桥0531-输出Y
    蓝桥0615-判断四位数字前后两组是否相等
  • 原文地址:https://www.cnblogs.com/chenyangpeng/p/5475405.html
Copyright © 2011-2022 走看看