zoukankan      html  css  js  c++  java
  • SQL 课堂随笔。。。

      SSMS 数据库服务所在电脑的ip地址     

    .      cocal // 本意 存在.mdf 文件里

     SQL 数据库平台     创建表,    增 删 改 查 

    net stop mssqlserver  停止

    net start mssqlserver  运行

    .mdf 数据文件,   有且只有一个

    .ldf  日志文件, 有且至少有一个

    表, 区域划分。 一个数据库里面有N个表

     

    create创建     table表 

    *所有的  where. 筛选条件 

      primary key主 键   identity不变的恒定式,(,)自增长

    //code int primary key, 设置主键的序列号

      varchar(max)数据类型就是和string一个意思,后面max是无限大的意思

    // name varchar(50)not null,

       insert into  插入到什么里面(插入到某个位置)    values 价值标准

       // intsert into+表名称+values(录入的数据内容)

    select 挑选  from 来自

    // select*from+表名称    //查询的意思

    delete 删除       drop 删除(大)      table 表  from 来自

    //delete from+表名称+ where code=2  //删除来自这个表的在 学号是2的地方内容

    update 校正,修正   set 我即将改成某个值  where 我要找到某个值      and 并且

    //update+表名称+set sex='0',age=22 where code=4

    between 从哪到哪 就好比是大于-小于

    create database 创建数据库       database 数据库

     not null 不能为空

       distinct去重  order by 排序  asc---升序  desc---降序

    //select*from student12 order by age asc,cm , kg desc-------//再不改变第一组排序结果基础上,再排第二次序是排不出来的。

    //-----分组group by列,对那一列进行分组,就只能显示哪一列
    select name  from student12 group by name---//对某一列分组,相当于去重显示

    写个练习:

    create  table student12 ---------------创建一个数据表 student12
    (
    code int primary key  identity(1,1), --给序号设置主键一一按顺序忘下排列
    name varchar(50) not null,
    sex varchar(50) not null,
    age int  not null,
    sg  int  not null,
    wuqi varchar(50)not null,
    dizhi varchar(max)not null,
    )

    insert into  student12 values('约里克','男',18,175,'洛阳铲','暗影岛'); --第一个人,约里克,男,18岁,身高175cm,武器是洛阳铲,来自暗影岛
    insert into  student12 values('拉克丝','男',25,188,'青龙偃月刀','弗雷尔桌德');
    insert into  student12 values('布兰德','男',22,180,'炽焰','诺克萨斯');
    insert into  student12 values('泽拉斯','男',17,179,'奥数雷电','艾欧尼亚');
    insert into  student12 values('奥莉安娜','女',20,170,'机械球','艾欧尼亚');
    insert into  student12 values('盖伦','男',25,185,'大宝剑','德玛西亚')
    insert into  student12 values('盖伦','男',28,190,'大宝剑','德玛西亚')

    go

    select*from student12 select*from student12 where cm>=170 and  kg>=65-------查询

    go

    update student12 set name='拉克丝' where name='蛮王' --set 我即将改成某个值,where 我要找到某个值,上面的拉克丝是已经改过运行之后的

    select*from student12 where kg between 65and 70

    select*from student12 where name like  '约%'           --like 好像的意思,百分号的意思是约后面可以有任何字

    select*from student12 where name like  '%拉%' --找到名字带有"拉"这个字的人,百分号也可以在前,找名字后面带”拉“的 

    update student12 set age=16 where code=7 --更改code

    delete from student12 where code=5 --删除code5这一行

     delete from  student12  where code between 10 and 13 --删除第10行到第13行数据          

    drop table student12--删除表 student12

    drop database yuelie--删除数据库 yuelie

    create database yuelie --创建数据库

    delete from student12   where code=6 and 10---删除第几行

     select top 3*from student12 where age>=20 ----------* 代表全部  top 第几行

  • 相关阅读:
    flutter 屏幕宽高 状态栏高度
    flutter 图片圆角
    flutter ListView嵌套高度问题
    Dubbo原码解析(version:2.5.3)
    ms
    InnoDB锁问题 & DB事务隔离级别
    Spring父容器与子容器
    Spring bean 的加载过程和生命周期
    logback
    Disconf (version : 2.6.21)
  • 原文地址:https://www.cnblogs.com/qiaoyifan3111/p/4442750.html
Copyright © 2011-2022 走看看