zoukankan      html  css  js  c++  java
  • SQL 数据库学习笔记

    SQL语法:

    在其他的数据库也能用;

    DDL--数据定义(greate teble,drop table,alter table)

    DML--数据操作语言(select,insert,update,delete);

     

     

     

    主键:

    生产 GUID 值的方法

    1,SQL中用 newid();

      默认值设定为newid的话可以自动插入ID

    2,c#中 Guid id = Guid.NewGuid();

     

     

    数据语法:

    //=====================================================

    创建表

    greate teble

    //=====================================================

    插入数据

    insert into person2(name,age) values('xuwei1',38);

    //=====================================================

    更新数据

    update person3 set age=age+20, name='xuwei'

     

    update person3 set name='gao'where age>=50 or age=60 

    //=====================================================

    删除数据

     

    delete from T_name; 清空数据

    drop T_name: 删除表 

     

    delete from person3  where age <50

     

    //=====================================================

    查询数据

     select

     

    数据汇总

     

    SQL 聚合函数 : MAX(最大值),MIN(最小值),AVG(平均值)

              SUM(和) COUNT(数量)

    大于25岁员工的最高工资: SELECT MAX(FSalary) FROM T_Employee

            WHERE FAge>25

     

    最低工资和最高工资: SELECT MIN(FSalary),MAX(FSalary) FROM                             T_Employee

     

     

    排序order by

     

        select * from person3 order by age ASC  按升序排

        select * from person3 order by age DESC,name asc                                                           按降序排

     //top 取值范围

        select top 3* from person3 order by age ASC

    //=====================================================

    通配符  LIKE

    select * from person3 where name like '_a_'

     

    多字符通配符 %

    select * from person3 where name like '%a%'

    //=====================================================

    空值的查询  is

     

    select *from person3 where name is null;

     

    select *from person3 where name is not null;

    //=====================================================

    分组   group by

     

    select age ,count(*) from person3 group by age;

     

    分组后信息过滤用having XX>9;

     

     

     

     

     

     

     

     

          

  • 相关阅读:
    Go 语言简介(下)— 特性
    Array.length vs Array.prototype.length
    【转】javascript Object使用Array的方法
    【转】大话程序猿眼里的高并发架构
    【转】The magic behind array length property
    【转】Build Your own Simplified AngularJS in 200 Lines of JavaScript
    【转】在 2016 年做 PHP 开发是一种什么样的体验?(一)
    【转】大话程序猿眼里的高并发
    php通过token验证表单重复提交
    windows 杀进程软件
  • 原文地址:https://www.cnblogs.com/crazyxu/p/2014010.html
Copyright © 2011-2022 走看看