Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to insert 100.000 test records into db?

Status
Not open for further replies.

01051965

Technical User
Nov 20, 2003
1
DE
Hi, can some one tell me how to insert dummy records into a postgresql table via a script(perl?).
Thnaks for advace
 
well not the best solution (especially it does generate only numbers, but cat be easily modified to get strings and it is written for php and can use COPY instead of INSERT, ... but ;-)))
________
pg_query($connection, 'begin');
for ($cnt = 0; $cnt < 100000; ++$cnt) {
pg_query($connection, &quot;INSERT INTO dest_table (field1, field2, field3) VALUES ('&quot;.rand(1, 1000).&quot;', '&quot;.random(1, 1000).&quot;', '&quot;.rand(1, 1000).&quot;')&quot;);
}
pg_query($connection, 'commit');

_______

this will generate fields with numbers from 1 to 1000 if text fields are needed you can make an array $letters with the letters from A to z and do $letters[rand(0, 51)]

or something like that if you need more meaningfull data ... write now I can't thing of a way
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top