Generate test data using Oracle PL/SQL developer(使用 Oracle PL/SQL developer 生成测试数据)
问题描述
我想测试一些模式和索引,我想知道 PL/SQL Developer 中是否有可以生成测试数据的功能(这样我就不必创建序列和循环来在表中插入数据).
I want to test some schemas and indexes, and I was wondering if there is a functionality in PL/SQL Developer that can generate test data (so I won't have to create sequences and loops to insert data in the tables).
推荐答案
循环和 PL/SQL 并不总是必要的;这个技巧可能会有所帮助:
Loops and PL/SQL aren't always necessary; this trick might be helpful:
insert into emp(id, name, salary)
select rownum, 'Employee ' || to_char(rownum), dbms_random.value(2, 9) * 1000
from dual
connect by level <= 100;
将生成 100 条记录,命名为 Employee 1 到 Employee 100,其工资在 2000 到 9000 之间是随机的.
will generate 100 records, named Employee 1 through Employee 100 with random "round" salaries between 2000 and 9000.
两种主要技术是:
- 使用
按级别连接 <= n在对偶查询中生成 n 行. dbms_random包的使用;还有一个非常有用的函数dbms_random.string,它可以用来——顾名思义——生成包含某些字符的特定长度的随机字符串.
- Use of
connect by level <= nto generate n rows in a query on dual. - Use of
dbms_randompackage; there's also a very useful functiondbms_random.stringwhich can be used -- like its name suggests -- to generate random strings of a certain length containing certain characters.
这篇关于使用 Oracle PL/SQL developer 生成测试数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Oracle PL/SQL developer 生成测试数据
基础教程推荐
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
