DamonYo0o 2017-09-16 02:17 采纳率: 100%
浏览 2281
已采纳

怎么能做到oracle批量修改数据?????

现在有一张表,数据量有十万,有一个字段是空的,现在要按数据量比例给这个字段设置三个不同的值,比如百分之三十的数据设置成1,百分之三十设置成2,剩下的百分之四十设置成3。比例无所谓不固定。
有没有大神教一下啊。。。

  • 写回答

2条回答 默认 最新

  • XianRenShan 2017-09-16 02:28
    关注

    --建表
    create table t (a number);
    --插入两条测试数据
    insert into t values(0);
    insert into t values(0);
    --测试语句
    select case
    when (select count(1) from t where t.a = 0) =
    (select count(1) from t) then
    '01'
    when (select count(1) from t where t.a = 0) <>
    (select count(1) from t) then
    '02'
    when (select count(1) from t where t.a = 2) <>
    (select count(1) from t) then
    '03'
    when (select count(1) from t where t.a = 2) = 0 then
    '04'
    else
    null
    end as b
    from dual;

    参考:http://bbs.csdn.net/topics/330059135
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?