惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 江城2211

大数值的精度与格式化显示问题 【知识总结】数据库的事务、并发与锁管理 基于数据源连接,动态构造JPA上下文EntityManager 【转载】使用了HTTPS为啥还要接口数据加密? RSA加密算法,加解密、签名示例 国密SM2算法,加密、签名示例 【知识总结】JVM线程堆栈中的基础概念解读 【问题记录】JVM进程崩溃(hs_err_pid.log致命错误日志) [问题记录】存在视图依赖的数据表,DDL修改字段比如做扩容等注意事项 【编码技巧】批量校验或处理关联引用数据的优化总结 【问题总结】Garmin路线无法同步和地图坐标偏移的解决办法 【工具推荐】磁盘IO检测工具之Diskspd - 江城2211 【编码技巧】总结一个稳定而高效的方法,将二维关系数据转换为树形结构 【编程技巧】结合JPA通用分页与排序技术,支持百万级以上数据的DML批量处理方案 【使用技巧】CodeDecom.exe批量反编译JAR包+Beyond Compare对比 【问题记录】Cause: java.sql.SQLRecoverableException: No more data to read from socket - 江城2211 JDBC与各数据库产品连接的驱动及URL示例 【问题记录】使用PowerDesigner连接数据库并反向工程生成所有表及关系 使用tcpdump抓取网络包,在wareshark查看对应请求及响应的原始报文
【编程技巧】SQL脚本快速生成随机测试数据
江城2211 · 2024-07-06 · via 博客园 - 江城2211

Oracle

create table TestTable as
  select lower(sys_guid()) AS guid,
         rownum as inc_id,
         trunc(dbms_random.value(0, 100)) as random_id,
         trunc(dbms_random.value()*power(10, 3), 8) as random_decimal1,
         trunc(dbms_random.value()*power(10, 8), 2) as random_decimal2,
         sysdate - 1 + rownum/24/3600 as inc_datetime,
         to_timestamp(systimestamp -1 + trunc(dbms_random.value(1, power(10, 8)))/24/3600)  as random_timestamp,
         substr( dbms_random.string('x', 100), 0, trunc(dbms_random.value(10, 100))) as random_string,
         to_clob(dbms_random.string('x', power(10, 6))) as random_clob
  from dual
     connect by level <= 1000000;

PostgreSQL

SELECT gen_random_uuid() guid
     , 'user_' || (power(10, 7) + rowIndex)  code
     , repeat('1',(random()*25)::integer) as name
     , rowIndex
     , (random()*100.)::numeric(4,2) random_decimal
     , TIMESTAMP '2022-01-01 00:00:00' + (TIMESTAMP '2022-12-31 23:59:59' - TIMESTAMP '2022-01-01 00:00:00') * random() AS random_timestamp
FROM generate_series(1, 1000000) rowIndex;

SQL Server & MySQL

select  floor(rand()*N)     --FLOOR 函数返回小于或等于所给数字表达式的最大整数。

select  ceiling(rand()*N)  --CEILING 函数返回大于或等于所给数字表达式的最小整数。

循环 或借助其他表进行查询插入

参考资料:

https://blog.csdn.net/lizhangyong1989/article/details/45013509 

https://blog.csdn.net/eagle89/article/details/116276102

https://www.cnblogs.com/terrence/p/4218741.html

https://www.jianshu.com/p/cf5d381ef637

https://www.cnblogs.com/CareySon/archive/2012/02/20/2359444.html

https://www.cnblogs.com/superfeeling/p/9199707.html

https://blog.csdn.net/mysqltop/article/details/105230327