Home  >  Article  >  Database  >  How to modify column value in oracle

How to modify column value in oracle

青灯夜游
青灯夜游Original
2022-01-13 10:43:458726browse

In Oracle, you can use the "update" command to modify the value of a column. This statement can be used to modify and update the data of one or more tables. The syntax is "update table name set column name 1=value 1, column name 2 = value 2, column name 3 = value 3.... where condition".

How to modify column value in oracle

The operating environment of this tutorial: Windows 7 system, Oracle 11g version, Dell G3 computer.

In Oracle, you can use the "update" command to modify the value of a column.

The update statement can be used to modify and update data in one or more tables.

Grammar:

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

Case 1. Update the age and ID card information of student "Zhang San":

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

The results are as follows:

How to modify column value in oracle

update The command structure to update the data in this table using another table association is as follows:

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

Case 2, update back using the backup table stuinfo_2018 The age and ID card of student "Zhang San":

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='张三';

The results are as follows:

How to modify column value in oracle

## Recommended tutorial: "

Oracle Tutorial

The above is the detailed content of How to modify column value in oracle. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn