469,903 Members | 1,911 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Best way to issue hundreds of inserts/updates???

Using mysql 4.0.23-

What is the best way to execute several (hundreds of) inserts and updates?
Rather than issuing tons of individual inserts and updates, can I send the
strings to a text file and then have mysql do them all??

IE :
query.txt

insert into table1 (col1,col2) values (1,2);
insert into table1 (col1,col2) values (9,4);
update table1 set col2=0 where col1=9;
insert into table1 (col1,col2) values (5,2);
insert into table1 (col1,col2) values (6,2);
insert into table1 (col1,col2) values (4,2);

Whats the best/fastest way to execute a few hundred of these?
Should I lock the table and then somehow use mysql.exe to run all the
commands in the txt file??

Any help appreciated...syntax also appreciated :-)
Craig
Jul 23 '05 #1
1 1760
"Craig Stadler" <cs********@hotmail.com> wrote in
news:fW**********************@news.easynews.com:
Using mysql 4.0.23-

What is the best way to execute several (hundreds of) inserts and
updates? Rather than issuing tons of individual inserts and updates,
can I send the strings to a text file and then have mysql do them
all??

IE :
query.txt

insert into table1 (col1,col2) values (1,2);
insert into table1 (col1,col2) values (9,4);
update table1 set col2=0 where col1=9;
insert into table1 (col1,col2) values (5,2);
insert into table1 (col1,col2) values (6,2);
insert into table1 (col1,col2) values (4,2);
yes, thats a good idea. it really mirrors the functionality and syntax of
a mysql dump file.

Whats the best/fastest way to execute a few hundred of these?
Should I lock the table and then somehow use mysql.exe to run all the
commands in the txt file??


go to your command prompt...

mysql -u <username> -p < query.txt
then you'll be prompted for your password, and a second or two later, your
updates will be done.
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Steve - DND | last post: by
2 posts views Thread by raisinodd | last post: by
reply views Thread by Dimitris Milonas | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.