http://dev.mysql.com/doc/mysql/en/truncate.html
solo da MySQL 4.0 ha cambiato modo di operare perché prima era un normalissimo delete senza where, comunque mi sembra troppo strano che la chiavi non vengano resettate se viene eliminato tutto, anche perché specifica chiaramente che (nella pagina riguardante il delete).
.
.
For other storage engines, TRUNCATE TABLE differs from DELETE FROM in the following ways from MySQL 4.0 and up:
*
Truncate operations drop and re-create the table, which is much faster than deleting rows one by one.
*
Truncate operations are not transaction-safe; you get an error if you have an active transaction or an active table lock.
*
The number of deleted rows is not returned.
*
As long as the table definition file tbl_name.frm is valid, the table can be re-created as an empty table with TRUNCATE TABLE, even if the data or index files have become corrupted.
*
The table handler does not remember the last used AUTO_INCREMENT value, but starts counting from the beginning. This is true even for MyISAM and InnoDB, which normally does not reuse sequence values.
In MySQL 3.23, TRUNCATE TABLE is mapped to COMMIT; DELETE FROM tbl_name, so it behaves like DELETE. See Section 13.2.1, “DELETE Syntax”.
TRUNCATE TABLE is an Oracle SQL extension. This statement was added in MySQL 3.23.28, although from 3.23.28 to 3.23.32, the keyword TABLE must be omitted.
If you issue a DELETE statement with no WHERE clause, all rows are deleted. A faster way to do this, when you don't want to know the number of deleted rows, is to use TRUNCATE TABLE. See Section 13.2.9, “TRUNCATE Syntax”.ora come possono dire usa truncate al posto di delete se hanno comportamenti differenti che non vengono specificati?Se usi un comando DELETE senza la clausola WHERE tutte le righe vengono eliminate. Un modo più veloce di farlo, quando a te non interessa sapere il numero di righe eliminate, è l'uso di TRUNCATE TABLE
Anche perché ... (tanto per essere precisi) ...
ovvero solo da MySQL 4 un comando delete senza where restituisce il numero di righe ... quindi prima di mysql 4 non c'era assolutamente e totalmente nessuna differenza ... ma cmq ritengo ancora assurdo il fatto che non vi sia un modo di resettare le chiavi usando la sintassi standardIn MySQL 3.23, DELETE without a WHERE clause returns zero as the number of affected records.
boh ... i misteri dell'informatica

Rispondi quotando