|
Posted by Michael Austin on 02/14/06 05:36
Chameleon wrote:
> I have a SQL Script with about 5000 SQL Commands.
>
> How can I send it to SQL Server at once?
>
> I see mysql_query() fails on first semicolon (;) who delimits the SQL
> Commands.
>
>
> Another question:
> I send to a MySQL server via fast Internet connection, about 500 INSERT
> commands one by one via mysql_query().
> It takes much time. Why?
> I suspect that, mysql_query() after send the query to server, waits for
> a "OK" response. If it's true, how can I send and send and send SQL
> commands and MySQL server reply "OK" after send all these things?
> (or no wait at all?)
A bit late, I know but it got me to thinking....
If you are going to insert 5000 rows into a database once or many times,
sometimes it is achieved much easier by using the LOAD FILE(MySQL), SQL*Loader
(Oracle), RMU/LOAD (Oracle Rdb) or DTS (Data Transformation Service (SQL Server)
to name a few. Use Bulk loaders for bulk load jobs - and life is much
easier... These tools even have exception handling for rows not loaded due to
bad data. You can use the previously stated methods, however, you must remember
to take into account the exceptions.
Exceptions can be:
Bad data (char in num field etc...)
Duplicate data (unique/{primary|foreign} key constraints in the db)
etc...
if one record fails - your entire transaction must be rolled back/undone to
preserve data integrity.
Yes, managing databases and data is quite complicated as the main goal is to
preserve data integrity at all cost. If not, it is not worth a dime to anyone.
my .10 worth :)
--
Michael Austin.
DBA Consultant
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Navigation:
[Reply to this message]
|