This is a discussion on Deleting all records in a table within the MySQL Database forums, part of the Database Forums category; How do I delete all records in a table instead of having to iterate through all the data using Python ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On Dec 21, 10:35 pm, "J.O. Aho" <u...@example.net> wrote:
> Vernon Wenberg III wrote: > > How do I delete all records in a table instead of having to iterate > > through all the data using Python and deleting by ID? > > DELETE FROM table > > -- > > //Aho Or just drop the table and then recreate it (minus the data). |
|
|||
|
"Vernon Wenberg III" <vwenberg@gmail.com> wrote in message news:K9Xaj.262440$Fc.252453@attbi_s21... > How do I delete all records in a table instead of having to iterate > through all the data using Python and deleting by ID? Here is the "standard" way. http://dev.mysql.com/doc/refman/5.0/en/truncate.html |
|
|||
|
On Sat, 22 Dec 2007 13:16:17 GMT, "Evan Keel"
<evankeel@sbcglobal.net> wrote: > >"Vernon Wenberg III" <vwenberg@gmail.com> wrote in message >news:K9Xaj.262440$Fc.252453@attbi_s21... >> How do I delete all records in a table instead of having to iterate >> through all the data using Python and deleting by ID? > >Here is the "standard" way. > >http://dev.mysql.com/doc/refman/5.0/en/truncate.html I'm very glad you "quoted" the word standard, because TRUNCATE is not very standard in relational database theory (and SQL). For example, ON DELETE triggers aren't invoked, and auto_increment counters are reset. That can easily ruin the integrity of a database. So, TRUNCATE is potentially very dangerous. I would consider it more a DBA tool than a programming statement, only to be used by experts. That's also the place it has in the SQL99 standard and in PostgreSQL. Though slower, the real standard way is DELETE FROM tablename; -- ( Kees ) c[_] Giving power and money to government is like giving whiskey and car-keys to teenage boys. (PJ O'Rourke) (#181) |