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

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
量子位
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
雷峰网
雷峰网
I
InfoQ
罗磊的独立博客
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
大猫的无限游戏
大猫的无限游戏
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
博客园 - 三生石上(FineUI控件)
The GitHub Blog
The GitHub Blog
K
Kaspersky official blog
P
Privacy & Cybersecurity Law Blog
S
SegmentFault 最新的问题
T
Threat Research - Cisco Blogs
H
Help Net Security
小众软件
小众软件
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CERT Recently Published Vulnerability Notes
WordPress大学
WordPress大学
T
Tenable Blog
T
The Blog of Author Tim Ferriss
C
Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
博客园 - Franky
A
Arctic Wolf
T
Threatpost
Scott Helme
Scott Helme
C
Cybersecurity and Infrastructure Security Agency CISA
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
The Exploit Database - CXSecurity.com
G
GRAHAM CLULEY
Security Latest
Security Latest
Spread Privacy
Spread Privacy
L
LINUX DO - 热门话题
V
Vulnerabilities – Threatpost
P
Privacy International News Feed
S
Schneier on Security
Latest news
Latest news
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com

博客园 - 江城2211

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

Posted on 2024-07-06 15:45  江城2211  阅读(184)  评论()    收藏  举报

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