oracle中update更新数据示例

发布时间:2020-05-30编辑:脚本学堂
分享下oracle数据库中update语句更新数据库的例子,有需要的朋友参考下。

在oracle中使用update更新数据。

1,使用表达式更新数据
 

复制代码 代码示例:

update table set column1 = value1,colunm2 = value2 where condition

update emp set sal = 1900 where ename = 'SCOTT'

select sal from emp where ename = 'SCOTT'

update emp set sal = 1800,comm = 234 where ename = 'SCOTT'

select ename,sal,comm from emp where ename = 'SCOTT'

select empno,ename,hiredate from emp where empno = 7788

update emp set hiredate = to_date('1984/01/01','YYYY/MM/DD') where empno =7788

select empno,ename,hiredate from emp where empno = 7788

2,使用子查询更新数据
 

复制代码 代码示例:

update emp set comm = 200 where ename = 'SMITH'

select job,sal,comm from emp where ename = 'SMITH'

update emp set job = 'CLERK',sal = 2200,comm = 200 where ename = 'SCOTT'

update emp set (job,sal,comm) = (select job,sal,comm from emp where ename = 'SMITH')where ename = 'SCOTT'

select ename,job,sal,comm from emp where ename = 'SCOTT'