Forum Moderators: coopster

Message Too Old, No Replies

Inserting with PHP 100 K rows in a table

Best way?

         

henry0

2:45 pm on Oct 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I need to insert in a table roughly 100K rows
Obviously PMA is giving up
What are my options short of chunking the insert?
If the only choice is the command line, I am not proficient enough with it
Please point me to a tutorial
thanks

coopster

3:06 pm on Oct 24, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I use the command line exclusively. Typically in a case like this I would already have the INSERT statement in a text file and then use the command line like this ...

#prompt>
mysql -h localhost -u username -p databasename < /path/to/inserts.sql
Enter password:
*******
#prompt>


... where
#prompt>
is the command prompt.

coopster

3:08 pm on Oct 24, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Additionally, do a backup on the table before you get started. I always create a backup before playing around at the command line and/or manipulating data in tables using external files in this manner.

henry0

3:47 pm on Oct 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That, I can understand!
thanks a lot for the code sample.

But due to the DB size
I will also need using the same command line for the backup
could you show me the way

coopster

4:10 pm on Oct 24, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Sure. This page will also come in handy:
[dev.mysql.com...]

#prompt>
mysqldump -h localhost -u username -p databasename > /path/to/databasebackup.sql
Enter password:
*******
#prompt>

henry0

5:46 pm on Oct 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks again
exactly what the good doc recommended :)