Operating System - HP-UX
1745852 Members
4512 Online
108723 Solutions
New Discussion юеВ

Re: Need script to fill up the database table

 
SOLVED
Go to solution
Deanna Tran
Frequent Advisor

Need script to fill up the database table

Does any one have any sample script that would help me to fill up the database table ?
7 REPLIES 7
Printaporn_1
Esteemed Contributor

Re: Need script to fill up the database table

usr SQL:
insert into
select * from < another table with same structure as your table>
enjoy any little thing in my life
H.Merijn Brand (procura
Honored Contributor

Re: Need script to fill up the database table

#!/opt/perl/bin/perl -w

use DBI;

my $dbh = DBI->connect (.....);
my $sth = $dbh->prepare (q;
insert into table values (?, ?, ?, ?););
foreach (0 .. 1_000_000) {
$sth->execute ($_, "$_", 1, "A");
}
$sth->finish;
$dbh->commit;
Enjoy, Have FUN! H.Merijn
Victor Geere
Frequent Advisor

Re: Need script to fill up the database table

create one record in the table that you want to fill up.

then

insert into TheTable (select * from TheTable);

run this a couple of times and you will have
1,2,4,8,16,32,64,128... etc. records in the table after each run.

I thought that I was because I had thought.
Brian Crabtree
Honored Contributor
Solution

Re: Need script to fill up the database table

create table tmptable (currnum number, junkinfo varchar2(10));

declare
numcount number;
begin
numcount:=0
while currnum < 10000 loop
numcount:=numcount+1;
insert into tmptable values (numcount,'ABCDEFG');
end loop;
end;
/
Brian Crabtree
Honored Contributor

Re: Need script to fill up the database table

Excuse me, that should read:

while numcount < 10000 loop
Deanna Tran
Frequent Advisor

Re: Need script to fill up the database table

HI brian,
I used it your script , but when i try to run it, it gives me error...actually i modified the script to have it run indefinitely..and this is the error that i got

here is the script
declare
numcount number;
begin
numcount:=1800
while (numcount-1) < 100000 loop
numcount:=numcount+1;
insert into employees value(numcount,'dfkjebkg','dljlkhgoi',6789.34,623495098);
end loop;
end;
/




while (numcount-1) < 100000 loop
*
ERROR at line 5:
ORA-06550: line 5, column 1:
PLS-00103: Encountered the symbol "WHILE" when expecting one of the following:
* & = - + ; < / > at in is mod not rem
<> or != or ~= >= <= <> and or like between ||
The symbol "*" was substituted for "WHILE" to continue.
ORA-06550: line 5, column 29:
PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:
* & - + ; / at mod rem and or ||
ORA-06550: line 7, column 1:
PLS-00103: Encountered the symbol "INSERT" when expecting one of the following:
begin function package pragma procedure subtype type use
Brian Crabtree
Honored Contributor

Re: Need script to fill up the database table

It looks like you need a ";" on the "numcount:=1800". It is expecting that, and it is finding the "while". Also, you will not want to run this indefinately, as there is a finite amount of rollback on the database. You will want to either terminate the program, or put another variable in that will perform a commit after a set number of records.

Brian