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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to delete all records from MySQL server using ODBC

Status
Not open for further replies.

gjbroek

Technical User
Jun 1, 2005
10
NL
Hi,

What is the easiest and fastest way to delete all records from a table in a MySQL table using an ODBC view.

Using doesn't work for many reasons (sometimes "connection busy", sometimes "update conflict"):

select table_view
requery()
delete all
= tableupdate(1,.T.)

Deleting record by record after a requery is stable, but way too slow. Any suggestions?

Regards, Gerrit
 
Can you use SQL Passthrough and issue DELETE FROM <table>?

Craig Berntson
MCSD, Visual FoxPro MVP, Author, CrysDev: A Developer's Guide to Integrating Crystal Reports&quot;
 

Gerrit,

Something like this:

Code:
lnConn = SQLCONNECT("MyDSN", "MyLogin", "MyPassword")
SQLEXEC(lnConn, "DELETE FROM MyTable")
SQLDISCONNECT(loConn)

In SQL Server, you can make this much faster by switching off logging while the delete is in progress. I don't know if MySQL lets you do that as well -- might be worth checking.

Also, check to see if MySQL supprts TRUNCATE TABLE. If so, that would be even faster.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Thanks!

This is just what I need.
Speed realy makes the difference...

Regards, Gerrit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top