Hi,
The following script does the job with one connection to the database however I need to add routines to make multiple connections to the database to do the job like adding another variable for example $conn=20; and avoid the table name conflicts, can someone please help me do that.
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $tables=1000;
my $rows=100000;
my $dbh = DBI->connect ('DBI:Oracle:host=EM12;sid=orcl',"hr","hr")
or die "Failed to connect to database: " . DBI->errstr;
for my $i (1..$tables) {
my $sql = "CREATE TABLE test_data$i(".
"id PRIMARY KEY,".
"group_id NOT NULL,".
"created_at NOT NULL,".
"text NOT NULL) AS ".
"SELECT ".
"rownum,".
"MOD(rownum, 5),".
"TO_DATE('1-jan-07', '
+dd-mon-yy') + INTERVAL '1' MINUTE * rownum,".
"CAST ('xyz' || rownum
+ AS VARCHAR2(50)) ".
"FROM dual ".
"CONNECT BY LEVEL <= $rows";
$dbh->do($sql) or die DBI->errstr;
}
$dbh->disconnect;
Thank you very much in advance.
Regards
Terry
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|