• 热点
  • 图片
  • 科技
  • 娱乐
  • 游戏
  • 体育
  • 汽车
  • 财经
  • 搞笑
  • 军事
  • 国际
  • 时尚
  • 旅游
  • 探索
  • 育儿
  • 养生
  • 美文
  • 历史
  • 美食
  • 当前位置: 小苹果范文网 > 军事 > 正文

    sql基本语句【sql语句总结】

    时间:2018-07-12 20:00:46 来源:小苹果范文网 本文已影响 小苹果范文网手机站

    sql语句总结

    sql语句

    1.查看学生表for update

    select * from STUDENT forupdate

    2.加一列ku

    altertable student add ku varchar(20)

    3.增加主键

    altertable student addconstraint 学号 primarykey (xh)

    4.重命名

    altertable student renamecolumn xh to 学号

    5.删除列

    altertable student dropcolumn czd

    6.更改字符

    altertable student modify xb varchar(20)

    7.设置唯一

    altertable student modify sfzh unique

    8.删除行

    deletefrom student where gao = '白'

    9.删除行

    deletefrom student where sfzh isnull

    10.删除列

    altertable student dropcolumn dh

    11.重命名

    altertable student renamecolumn xm to 姓名

    12.改字符

    altertable student modify 姓名 varchar(20)

    13.设置默认

    altertable student modify 姓名 default'白'

    14.删除行

    deletefrom student where xb = '女'

    15.增加列

    altertable student add ha date

    16.删除列

    altertable student dropcolumn ha

    17.增加主键

    altertable student addconstraint 主见 primarykey (xb)

    18.清空表

    truncatetable student

    19.删除表

    droptable student

    20.增加列

    altertable student2 add cu varchar(20)

    21.删除列

    altertable student2 dropcolumn cu

    22.删除表

    droptable 学生信息表

    23.删除表

    droptable 图书借阅信息表

    24.查看表信息

    select * from 图书基本信息表

    25.删除列

    altertable 图书基本信息表 dropcolumn 图书编码

    26.删除列

    altertable 图书基本信息表 dropcolumn 书名

    27.删除行

    deletefrom 图书基本信息表 where 作者 like'张%'

    28.删除行

    deletefrom 图书基本信息表 where 出版单位 like'%社'

    29.删除表

    droptable 图书基本信息表

    30.删除表

    droptable 图书表

    31.建表

    createtable xsb

    (

    xh varchar(10) primarykey,

    xm varchar(10) uniquecheck (xm like'唐%'),

    xb varchar(10) notnull,

    cj varchar(10) default'缺考'

    )

    32.更改表内容

    update xsb set cj=100,xb='男'where xh = '白洁'

    update xsb set xm='唐4',xh=5where xb = '男'

    updatexsb set cj=120where xb like'男%'

    33.练习子查询

    select * from student where sfzh in (select sfzh from(select sfzh,count(*) from student

    groupby sfzh havingcount(*)》1))

    34.练习分组

    select sfzh,count(*) from student

    groupby sfzh havingcount(*)》1

    • 生活居家
    • 情感人生
    • 社会财经
    • 文化
    • 职场
    • 教育
    • 电脑上网