构造能随机读取元素的SQL语句
select case mod( abs (dbms_random.random), 5 ) when 1 then ‘ 北京 ‘ when 2 then ‘ 上海 ‘ when 3 then ‘ 广州 ‘ when 4 then ‘ 深圳 ‘ else ‘ 武汉 ‘ end "LOC" from dual;
大批量填充test表的loc字段
begin for i in 1 .. 10 loop insert into test values ( case mod( abs (dbms_random.random), 5 ) when 1 then ‘ 北京 ‘ when 2 then ‘ 上海 ‘ when 3 then ‘ 广州 ‘ when 4 then ‘ 深圳 ‘ else ‘ 武汉 ‘ end ); end loop; end ;
最后生成的结果如下:
SQL > select * from test; LOC -- ------ 武汉 广州 上海 北京 上海 武汉 北京 上海 武汉 深圳 10 rows selected.
Oracle如何实现从特定组合中随机读取值
标签:
查看更多关于Oracle如何实现从特定组合中随机读取值的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did119241