473,473 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1870
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tim Callaghan | last post by:
We have an inhouse replication process which is causing us headaches when we try to run more than one copy of it against the same target database (we support unlimited remote databases so we may...
2
by: L. Blunt | last post by:
Hopefully someone can at least point me in the right direction for more research (e.g.: correct terminology). My only previous experience was just dumping data into a database using ODBC, and that...
3
by: Viswanatha Thalakola | last post by:
Hello, Can someone point me to getting the total number of inserts and updates on a table over a period of time? I just want to measure the insert and update activity on the tables. Thanks....
1
by: TammyZ | last post by:
I have developed an Access 2000 application: front-end as a run-time on user's desktops, and the back-end database on the server. I need help with ensuring that all the code that I have...
0
by: Steve - DND | last post by:
Is there a way to perform multiple inserts and updates to SQL Server with stored procedures and the Command object's named parameters all at once? The only way to do this that I'm gathering so far...
2
by: raisinodd | last post by:
Sorry for cross posting, just realised myodbc wasn't the place for this: Hello, I'm having a problem with records inserted using NOW() as data in a field having that timestamp updated when I...
0
by: Dimitris Milonas | last post by:
Hello to all, I have a DetailView on a page with Insert/Update enable and Paging enable. I would like to have on the same page two buttons ("Submit" and "Cancel") where with the first ("Submit")...
4
by: shreyask | last post by:
I have been working on doing bulk updates and inserts through sqlapi++ using a bulk udpate extention library, developed, a long time ago, internally. The database is oracle. The bulk inserts/updates...
0
by: 1477v | last post by:
Hi, I've written a couple adapter type applications to grab insert, update and delete operations on desired tables of my DB2 database. One application is based on installing and using triggers...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.