oracle update语句的几点写法

update两表关联的写法包括字查询

1.update t2 set parentid=(select ownerid from t1 where t1.id=t2.id);

2. 
update tb_client_win_lost_report a set a.rolling_code_id=2 
where game_code_id=70000 
and exists 
(select ‘x‘ from (select a.id 
from (select id,level_ from tb_admin_role connect by prior id=parent_id start with id =1) a, 
(select lv_id from tb_rolling_plan where rolling_code_id = 2 and game_code_id=70000) b 
where b.lv_id=a.id) c where a.role_id=c.id) 
and rolling_code_id=1

3. 
update (select rolling_code_id from tb_client_win_lost_report a,temp_role_id b 
where a.role_id=b.id 
and rolling_code_id=1) a set a.rolling_code_id=2;

4. 
update tb_client_win_lost_report a set a.rolling_code_id=2 
where game_code_id=70000 
and exists 
(select ‘x‘ from (select id from temp_role_id) c where a.role_id=c.id) 
and rolling_code_id=1 
and rownum<100000; 
commit;

5.

update 多个字段的写法 
update a set (c1,c2,c3) =(select b1,b2,b3 from b where......) where ......;

时间: 2024-08-27 13:37:20

oracle update语句的几点写法的相关文章

Oracle Update 语句语法与性能分析 - 多表关联

Oracle Update 语句语法与性能分析 - 多表关联 为了方便起见,建立了以下简单模型,和构造了部分测试数据: 在某个业务受理子系统BSS中, SQL 代码 --客户资料表 create table customers ( customer_id number(8) not null, -- 客户标示 city_name varchar2(10) not null, -- 所在城市 customer_type char(2) not null, -- 客户类型 ... ) create

oracle update语句卡住问题

执行update语句的时候发现执行半天不成功 update main_order set order_source = '2', order_status = '2' 查询哪些对象被锁 select object_name, machine, s.sid, s.serial# from v$locked_object l, dba_objects o , v$session s where l.object_id = o.object_id and l.session_id=s.sid; 查询出

oracle update语句

Oracle在表中更新数据的语法是: 语法结构:UPDATE操作 UPDATE 表名 SET 列名1=值,列名2=值-- WHERE 条件 代码演示:UPDATE操作 SQL> UPDATE INFOS SET CLASSNO='1002',STUADDRESS='山东莱芜' WHERE STUNAME='阮小二';

Oracle的update语句优化研究

最近研究sql优化,以下文章转自互联网: 1.     语法 单表:UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值 如:update t_join_situation set join_state='1'whereyear='2011' 更新年度为“2011”的数据的join_state字段为“1”.如果更新的字段加了索引,更新时会重建索引,更新效率会慢. 多表关联,并把一个表的字段值更新到另一个表中的字段去: update 表a set a.字段1 = (sele

[转]Oracle的update语句优化研究

原文地址:http://blog.csdn.net/u011721927/article/details/39228001 一.         update语句的语法与原理 1.     语法 单表:UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值 如:update t_join_situation set join_state='1'whereyear='2011' 更新年度为"2011"的数据的join_state字段为"1".如果

[转载] ORACLE 多表关联 UPDATE 语句

为了方便起见,建立了以下简单模型,和构造了部分测试数据:在某个业务受理子系统BSS中, SQL 代码 1 --客户资料表 2 create table customers 3 ( 4 customer_id number(8) not null, -- 客户标示 5 city_name varchar2(10) not null, -- 所在城市 6 customer_type char(2) not null, -- 客户类型 7 ... 8 ) 9 create unique index P

ORACLE 多表关联 UPDATE 语句

为了方便起见,建立了以下简单模型,和构造了部分测试数据:在某个业务受理子系统BSS中, SQL 代码 --客户资料表 create table customers ( customer_id number(8) not null, -- 客户标示 city_name varchar2(10) not null, -- 所在城市 customer_type char(2) not null, -- 客户类型 ... ) create unique index PK_customers on cus

Oracle 增删改(INSERT、DELETE、UPDATE)语句

?  简介 本文介绍 Oracle 中的增删改语句,即 INSERT.DELETE.UPDATE 语句的使用.是时候展现真正的技术了,快上车: 1.   插入数据(INSERT) 2.   修改数据(UPDATE) 3.   删除数据(DELETE) 4.   注意事项 1.   插入数据(INSERT) u  语法: INSERT INTO TABLE_NAME [(column1[, column2-]] VALUES(value1[, value2-]); 说明: 1)   INSERT

[Oracle] Merge语句

Merge的语法如下: MERGE [hint] INTO [schema .] table [t_alias] USING [schema .] { table | view | subquery } [t_alias] ON ( condition ) WHEN MATCHED THEN merge_update_clause WHEN NOT MATCHED THEN merge_insert_clause; MERGE是什么,如何使用呢?让我们先看一个简单的需求: 需求是,从T1表更新数