« MySQL/Manipulation de données » : différence entre les versions

Contenu supprimé Contenu ajouté
Ligne 91 :
Avant MySQL 4.0.1, <code>INSERT ... SELECT</code> opérait implicitement en mode <code>IGNORE</code> : ignorer les enregistrements qui causeraient des erreurs de valeur de clé dupliquée.
 
== DELETE andet TRUNCATE ==
<source lang=sql>
DELETE [QUICK] FROM `table1`
TRUNCATE [TABLE] `table1`
</source>
* Utiliser <code>DELETE</code> sans clause <code>WHERE</code>, supprime tous les enregistrements.
* If you don't use a WHERE clause with DELETE, all records will be deleted.
* Si une table contient beaucoup d'index, on peut agrandir le cache pour accélérer les <code>DELETE</code> (variable <code>key_buffer_size</code>).
* It can be very slow in a large table, especially if the table has many indexes.
* If the table has many indexes, you can make the cache larger to try making the DELETE faster (key_buffer_size variable).
* For indexed MyISAM tables, in some cases DELETEs are faster if you specify the QUICK keyword (DELETE QUICK FROM ...). This is only useful for tables where DELETEd index values will be reused.
* TRUNCATE will delete all rows quickly by DROPping and reCREATE-ing the table (not all Storage Engines support this operation).
Ligne 113 ⟶ 112 :
You can order the rows before deleting them, and then delete only a given number of rows.
 
== Références ==
{{Références}}
 
[[en:MySQL/Language/Data manipulation]]