• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
成为自己最想成为的那种人
博客园    首页    新随笔    联系   管理    订阅  订阅
插入数据、修改数据、删除数据

1. 插入数据

  插入单个元组:

      insert

      into Student (Sno, Sname, Ssex, Sdept, Sage )

      values ('95020', '陈东', '男', 'IS', 18);

  插入一条记录(完整的):

      insert

      into Student

      values ('95020', …… , 18, 'CS');    //按顺序

  插入子查询结果:

      select 子句目标列必须与 into 子句匹配 

      insert

      into Deptage (Sdept, Avgage)

          select Sdept, AVG (Sage)

          from Student

          group by  ;

2. 修改数据

  ① update Student          ③ update SC

    set sage = 22             set Grade = 0

    where Sno = '95001';         where 'CS' = ( select Sdept

                            from Student

  ② update Student                where Student.Sno = SC.Sno );

    set sage = sage + 1;

3. 删除数据

  ① delete                 ③ delete

    from Student                from SC

    where Sno = '95019';           where 'CS' = ( select sdept

                              from Student

  ② delete                       where Student.Sno = SC.Sno );

    from SC    //删除所有的学生选课记录

 

posted on 2017-06-05 11:41  遇见未来  阅读(616)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3