使用Oracle PL / SQL开发人员生成测试数据 [英] Generate test data using Oracle PL/SQL developer
本文介绍了使用Oracle PL / SQL开发人员生成测试数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想测试一些模式和索引,我想知道在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.
两种主要的技术是:
- 使用<$ c $
- 使用
dbms_random $ c> $ c> package;还有一个非常有用的函数
dbms_random.string
,可以使用它 - 像它的名字所示 - 生成包含某些字符的某个长度的随机字符串。
- Use of
connect by level <= n
to generate n rows in a query on dual. - Use of
dbms_random
package; there's also a very useful functiondbms_random.string
which can be used -- like its name suggests -- to generate random strings of a certain length containing certain characters.
这篇关于使用Oracle PL / SQL开发人员生成测试数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文