- 将字符串转为多列
select regexp_substr('1,2,3,4,5','[^,]+',1,rownum) as col
from dual
connect by rownum<=length('1,2,3,4,5')-length(replace('1,2,3,4,5',','))+1;
select listagg(o.orgname,',') within group(order by level)
from organization o
start with o.orgid = 1000 connect by prior o.orgid = o.pid and level<4;
- 随机取一条数据
select * from
(select * from org order by dbms_random.value())
where rownum=1;
#oracle sample语法随机取一行数据
select * from org sample(1) where rownum=1;
#“全表扫描”随机抽取10%的记录,随机查询5条记录
select * from org sample(10) where rownum<6
#从表zeeno中“采样表扫描”随机抽取10%的记录,随机查询5条记录
select * from org sample block(10) where rownum<6;
#使用seed,返回固定的结果集。从表zeeno中“采样表扫描”随机抽取10%的记录,随机查询5条记录。
select * from org sample(10) seed(10) where rownum<6;
- 随机生成18位字符串
select lpad(abs(mod(dbms_random.random,1000000)),6,0)||to_char(current_date,'YYMMDDhh24miSS')
from dual;
lpad(字段名,填充长度,填充的字符)
mod(x,y)返回X除以Y的余数
abs(x) 取绝对值
博客介绍了Oracle数据库的相关操作技巧,包括将字符串转为多列、多行数据转成一行,还提及随机取数据、生成18位字符串,以及lpad函数、mod函数和abs函数的使用。

被折叠的 条评论
为什么被折叠?



