Oracle 两个表之间更新的实现
Oracle 两个表之间更新的实现
前提条件:
表info_user中有字段id和name,字段id为索引
表data_user_info中有字段id和name,字段id为索引
其中表info_user中字段id和表data_user_info中字段id数值一致。
要求实现:
更新表info_user中的字段name 与表data_user_info中字段name一致。
实现的SQL语句为:
update info_user i set (i.name) = (select d.name from data_user_info d where d.id = i.id)
where i.id = (select d.id from data_user_info d where d.id = i.id);
commit;
-------------------------分割线-------------------------
Oracle中,如果跨两个表进行更新,Sql语句写成这样
Update Table a set a.ID=Table2.ID where a.Name = Table2.Name
Oracle 不会通过。查了资料,,Sql语句需要这样写才行
Update Table a set a.ID=(select b.ID from Table2 b where b.Name = a.Name ) where exist (select 1 from Table2 b where b.Name=a.Name)
更新多个字段也可以
Update Table a set a.ID=(select b.ID from Table2 b where b.Name = a.Name ),a.Code=(select b.Code from Table2 b where b.Name = a.Name ) where exist (select 1 from Table2 b where b.Name=a.Name)
Oracle 两个表之间更新的实现的更多相关文章
- 问题:oracle 两个表之间的修改;结果:ORACLE 两个表之间更新的实现
前提条件: 表info_user中有字段id和name,字段id为索引 表data_user_info中有字段id和name,字段id为索引 其中表info_user中字段id和表data_user_ ...
- Oracle两张表关联批量更新其中一张表的数据
Oracle两张表关联批量更新其中一张表的数据 方法一(推荐): UPDATE 表2 SET 表2.C = (SELECT B FROM 表1 WHERE 表1.A = 表2.A) WHERE EXI ...
- sqlserver 将 “用 特定字符 分隔的一个字段” 拆分成多个字段,然后两个表之间数据更新
将源TXT文件sourceFile_table.txt导入数据库,生成新表dbo.sourceFile_table.新增字段lon.lat.shi.xian 源表dbo.sourceFile_tabl ...
- EF Core中如何正确地设置两张表之间的关联关系
数据库 假设现在我们在SQL Server数据库中有下面两张表: Person表,代表的是一个人: CREATE TABLE [dbo].[Person]( ,) NOT NULL, ) NULL, ...
- mysql 查两个表之间的数据差集
需要查两个表之间的差集 首先,想到的是主键直接not in select mailbox_id from co_user where mailbox_id not in (select mailbox ...
- Oracle中truncate表不更新last_ddl_time列
Oracle中truncate表不更新last_ddl_time列 问题描述 最近发现数据库中定时job的某张表,每天都有truncate动作,由于调整了job的interval时间,想查看last_ ...
- JS之document例题讲解1(两张表之间数据转移、日期时间选择、子菜单下拉、用div做下拉菜单、事件总结)
作业一:两个列表之间数据从一个列表移动到另一个列表 <div style="width:600px; height:500px; margin-top:20px"> & ...
- 2016.2.13 (年初六) oracle两张表update方法
A表customers和B表tmp_cust_city有3个相同字段, customer_id,city_name,customer_type 现要根据b表更新a表 更新一个字段情况: update ...
- MySQL 两张表关联更新(用一个表的数据更新另一个表的数据)
有两张表,info1, info2 . info1: info2: 现在,要用info2中的数据更新info1中对应的学生信息,sql语句如下: UPDATE info1 t1 JOIN info2 ...
随机推荐
- CUDA代码的高亮设置
以下基于"WIN7(64位)+Visual Studio 2010+CUDA7.5". 语法高亮除了看起来舒服之外,还可以使用F11寻找函数.变量定义,输入函数的时候也会有相应的提 ...
- 【转】oracle查询用户表,函数,储存过程,
◆Oracle查询用户表空间:select * from user_all_tables ◆Oracle查询所有函数和储存过程:select * from user_source ◆Oracle查询所 ...
- Fedora22编译Qt3.3.X
FC22编译QT3 安装g++ dnf install gcc-c++ 1,configure ./configure -thread -no-nis -system-libpng -system-l ...
- 使用kindeditor文本编辑器
aspx中代码: <%@ Page Language="C#" ValidateRequest="false" AutoEventWireup=" ...
- css实现并列效果
<a href="#" class="mj-picList"> <div class="mj-picList-pic" s ...
- php的cookie和session相同主域名共享
如何使用chrome查看cookie和session详见另一篇文章,点这里 首先说cookie, $cookieDomain = '.elf.com'; setcookie('elf', 'im el ...
- iOS多线程 NSOperation的用法
上一篇写了 GCD 的使用,接下来就了解一下 NSOperation ,NSOperation是苹果对 GCD 的 OC 版的一个封装,但是相对于GCD来说可控性更强,并且可以加入操作依赖. NSOp ...
- Spring和mybatis整合后的mybais-config.xml配置
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE configuration PUBLIC & ...
- 后台返回字符串类型function的处理 (递归算法)
$(function(){ $.ajax({ type: "post", url: "${ctx}/modules/fos/reference/echart", ...
- 由Selenium1转变为Selenium2所遇到的问题
1.使用ant脚本运行测试,报NoClassDefError,但使用junit方式运行或debug,都没有错误. 原因:找不到包,但具体是哪个包,不清楚:且为何使用junit方式运行就没有问题,也不清 ...