• 技术文章 >数据库 >Oracle

    oracle如何修改列的值

    青灯夜游青灯夜游2022-01-13 10:43:45原创131

    在oracle中,可以使用“update”命令来修改列的值,该语句可以用来修改、更新一个或多个表的数据,语法为“update 表名 set 列名1=值1,列名2=值2,列名3=值3..... where 条件”。

    本教程操作环境:Windows7系统、Oracle 11g版、Dell G3电脑。

    在oracle中,可以使用“update”命令来修改列的值。

    update语句可以用来修改、更新一个或多个表的数据。

    语法:

    update 表名 set 列名1=值1,列名2=值2,列名3=值3..... where 条件

    案例1、更新学生“张三”的年龄和身份证信息:

    update student.stuinfo t
       set t.age = '24', t.idnumber = '3503021994XXXXXXXX'
     where t.stuname = '张三';
    commit;
    select * from student.stuinfo t where t.stuname='张三';

    结果如下:

    1.png

    update 利用另外一张表关联更新本表数据的命令结构如下:

    update 表1 set 列名=(select 列名 from 表2 where 表1.列名=表2.列名) 
           where exists (select 1 from 表2 where 表1.列名=表2.列名)

    案例2、利用备份表stuinfo_2018更新回学生“张三”的年龄和身份证:

    update student.stuinfo t
       set (age, idnumber) =
           (select age, idnumber from student.stuinfo_2018 b where b.stuid = t.stuid)
     where exists (select 1
              from student.stuinfo_2018 b
             where b.stuid = t.stuid
               and b.stuname = '张三');
               
    select *from student.stuinfo t where t.stuname='张三';

    结果如下:

    2.png

    推荐教程:《Oracle教程

    以上就是oracle如何修改列的值的详细内容,更多请关注php中文网其它相关文章!

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    上一篇:oracle怎么判断表是否存在 下一篇:oracle如何增加数据

    相关文章推荐

    • oracle怎样查询用户的表空间• oracle怎样查看存储过程• oracle怎样截取字符串后几位• oracle怎么转换字符集• oracle怎么查询指定用户的表空间

    全部评论我要评论

  • 取消发布评论发送
  • 1/1

    PHP中文网