oracle数据库update语句?

2025-03-24 13:17:38
推荐回答(3个)
回答1:

  1. 使用b表数据更新a表,那么where条件是什么,也就是说,更新a表中哪些数据,用b表中的哪些数据更新,二者的关系是什么。从你的语句中我看不出b表和a表的关联。

  2. 找到关联条件后,通过关联条件查出的b表数据是否唯一,如果不唯一,还是会出现“返回值多于一行”的错误。

  3. 按照你的表结构和数据,假设A表和B表中的name列唯一,以name作为关联,可以这样写来实现你的更新目的。

  4. update A set cou2 = (select B_cou1 from B where B.B_name = A.name) where name in (select B_name from B where B.B_name = A.name)

  5. 这条语句必须满足name在a、b表中唯一的条件,才能使用。

  • 甲骨文股份有限公司是全球大型数据库软件公司,总部位于美国加州红木城的红木岸。在2008年,甲骨文股份有限公司是继Microsoft及IBM后,全球收入第三多的软件公司。

  • Oracle数据库产品为财富排行榜上的前1000家公司所采用,许多大型网站也选用了Oracle系统。甲骨文股份有限公司于1989年正式进入中国,在北京、上海、广州和成都均设立了分支机构。

  • 2016年1月,甲骨文表示会收购网站数据追踪服务商AddThis。2016年2月,甲骨文收购了云计算创业公司Ravello Systems。2017年6月7日发布的2017年美国《财富》500强,甲骨文公司排名第81位。

  • 2017年6月,《2017年BrandZ最具价值全球品牌100强》公布,甲骨文公司排名第46位。

  • 20世纪约70年代一间名为Ampex的软件公司,为中央情报局设计一套名叫Oracle的数据库,埃里森是程序员之一。

回答2:

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 ......;

回答3:

update表明set字段1=值1,字段2=值2 查看原帖>>