PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Deleting all records in a table
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Deleting all records in a table

Réponse
 
LinkBack Outils de la discussion
Vieux 21/12/2007, 22h32   #1
Vernon Wenberg III
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Deleting all records in a table

How do I delete all records in a table instead of having to iterate
through all the data using Python and deleting by ID?
  Réponse avec citation
Vieux 21/12/2007, 22h35   #2
J.O. Aho
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Deleting all records in a table

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
  Réponse avec citation
Vieux 22/12/2007, 00h26   #3
strawberry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Deleting all records in a table

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).
  Réponse avec citation
Vieux 22/12/2007, 13h16   #4
Evan Keel
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Deleting all records in a table


"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


  Réponse avec citation
Vieux 22/12/2007, 19h15   #5
Kees Nuyt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Deleting all records in a table

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)
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 18h05.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11757 seconds with 13 queries