Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

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
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