update t_user_identification u
set u.customer_id = (select c.customer_id
from t_customer c
where exists (select 1
from t_user us
where us.customer_id = c.customer_id
and exists
(select 1
from t_user_login_way y
where y.user_id = us.user_id
and y.user_name = u.open_id
and y.user_type = ''))
and rownum <= 1)
where u.identify_status in ('');

上面的方法有个缺陷,当数据过多时,数据库会因为执行时间太长而报错ORA-01555,导致全盘扫描中断,

改成下面这样问题就都解决啦

declare
v_num number;
begin
v_num := 0;
for f in (select id,open_id from t_user_identification where identify_status = '') loop
update t_user_identification u
set u.customer_id = (select c.customer_id
from t_customer c
where exists (select 1
from t_user us
where us.customer_id = c.customer_id
and exists
(select 1
from t_user_login_way y
where y.user_id = us.user_id
and y.user_name = f.open_id
and y.user_type = ''))
and rownum <= 1)
where u.identify_status in ('') and u.id = f.id;
v_num := v_num + 1;
if v_num > 50 then
begin
commit;
v_num := 0;
end;
end if;
end loop;
commit;
end;

设置customer_id的更多相关文章

  1. Linux命令总结大全,包含所有linux命令

    使用说明:此文档包含所有的Linux命令,只有你想不到的没有你看不到的,此文档共计10万余字,有8400多行,预计阅读时间差不多需要3个小时左右,所以要给大家说一说如何阅读此文档 为了方便大家阅读,我 ...

  2. Mysql 外键设置

    MySql外键设置详解 (1) 外键的使用: 外键的作用,主要有两个:    一个是让数据库自己通过外键来保证数据的完整性和一致性    一个就是能够增加ER图的可读性    有些人认为外键的建立会给 ...

  3. 如何在MySQL中设置外键约束

    引用:http://blog.sina.com.cn/s/blog_53729e4601011wja.html MySql外键设置详解   (1) 外键的使用: 外键的作用,主要有两个:    一个是 ...

  4. SQL进阶-索引设置&sql优化

    一.索引设置 1.索引的设置原则 经常出现在WHERE条件.关联条件中的字段作为索引字段: 在满足查询需求的前提下,应尽可能少的创建索引:(对于一个组合索引,可以满足以组合索引左边的一部分字段的查询需 ...

  5. 【mysql】一对一关系的理解,以及Navicat Premium怎么设置字段的唯一性(UNIQUE)?

    背景:一对一关系设计方法: 设计2张表:customer表,student表 学生表中通过字段customer_id与customer表产生关系. student表中的customer_id与cust ...

  6. 【.net 深呼吸】设置序列化中的最大数据量

    欢迎收看本期的<老周吹牛>节目,由于剧组严重缺钱,故本节目无视频无声音.好,先看下面一个类声明. [DataContract] public class DemoObject { [Dat ...

  7. LINUX篇,设置MYSQL远程访问实用版

    每次设置root和远程访问都容易出现问题, 总结了个通用方法, 关键在于实用 step1: # mysql -u root mysql mysql> Grant all privileges o ...

  8. Visual Studio Code 代理设置

    Visual Studio Code (简称 VS Code)是由微软研发的一款免费.开源的跨平台文本(代码)编辑器,在十多年的编程经历中,我使用过非常多的的代码编辑器(包括 IDE),例如 Fron ...

  9. myeclipse学习总结一(在MyEclipse中设置生成jsp页面时默认编码为utf-8编码)

    1.每次我们在MyEclispe中创建Jsp页面,生成的Jsp页面的默认编码是"ISO-8859-1".在这种情况下,当我们在页面中编写的内容存在中文的时候,就无法进行保存.如下图 ...

随机推荐

  1. html标签一

    <body></body> 网页内容 <p></p>段落 <h1></h1> ----<h6></h6> ...

  2. Git二进制文件冲突解决

    Git二进制文件冲突解决 在我们合并分支的时候,如果两个分支都进行了修改那么就会产生合并冲突.对于非二进制文件的冲突解决,git会给出冲突的位置我们可以手动修改然后再commit.但是对于非二进制文件 ...

  3. linux利用crontab设置定时任务运行jar包

    参考链接: 1.http://blog.csdn.net/javadhh/article/details/42779505 2.http://blog.csdn.net/cctv_liu/articl ...

  4. pycharm 创建文件时,自动添加文件头注释

    File->settings->Editor->File and Code Templates->Python Script # -*- coding: utf-8 -*- & ...

  5. 谁说delphi没有IOCP库,delphi新的IOCP类库,开源中: DIOCP组件JSON流模块说明

    单元:JSonStream.pas 简介:本单元实现 流和json对象的相互转换,其中有一些保留的key. 依赖:superobject 保留key: __result.errCode  返回的错误编 ...

  6. sscanf 解析字符串

    test.txt中内容如下所示: eth0||192.168.0.2-192.168.0.150 eth2||192.168.0.2-192.168.0.150 想要将其中的ip地址等解析出来: #i ...

  7. .Net直接将Web页面table导出到Excel

    项目管理系统有个统计表需要导出到Excel表中.常用的方法是在后台C#代码查询数据再写入Excel表中最后保存在目标路径. 为减轻数据库服务器的压力和保持页面的样式,能否直接将页面的表格直接导出到Ex ...

  8. java 中jar的使用

    ????????????这里不会 需要学习

  9. New users can not log on Win8

    方案: http://www.eightforums.com/tutorials/38838-user-profile-service-failed-sign-fix-windows-8-a.html ...

  10. rails 查看项目的所有路由

    rails routes