MyBatis-------oracle中获取随机数方法(造数据)
一、随机数
update M_XS_JY set JYLX=cast( floor(dbms_random.value(1,15)) as int);
参考:https://www.cnblogs.com/blogyuan/p/3739638.html
二、随机字母
用法是DBMS_RANDOM.STRING(选项, 返回字符串长度)
SELECT DBMS_RANDOM.STRING('u',1) FROM dual;
选项有如下几种可供选择:
1)'u', 'U' - returning string in uppercase alpha characters
2)'l', 'L' - returning string in lowercase alpha characters
3)'a', 'A' - returning string in mixed case alpha characters
4)'x', 'X' - returning string in uppercase alpha-numeric characters
5)'p', 'P' - returning string in any printable characters.
6)Otherwise the returning string is in uppercase alpha characters.
http://blog.itpub.net/25746731/viewspace-693735/
三、主键
sys_guid()
INSERT INTO M_XS_JY
SELECT sys_guid(), "XH", "JYDWSFBM", "JYNF", "JYLX", "JYDWCSBM", "JYHY", "JYDWXZ", "JYDWMC" FROM M_XS_JY
四、循环执行SQL
循环执行1000次
declare
i integer;
begin
i:=0;
for i in 1..1000 loop
insert into hvm_zsb_tj t (t.id,t.stsres,t.bdzdydj,t.byq) values(t_hvm_seq.nextval,'a','a',1);
end loop;
end;
五、取表中随机数
select * from (select * from staff order by dbms_random.random)
where rownum < 4
六、插入随机值
七、更新字段为随机值(不带关联关系)