Truncate usage
TRUNCATE [TABLE] Tbl_name
I want to delete all the records in the Friends table, you can use the following statement:
TRUNCATE TABLE friends;
Delete Usage
DELETE [low_priority] [QUICK] [IGNORE] from Tbl_name
[WHERE Where_definition]
[Order BY ...]
[LIMIT Row_count]
Multiple table syntax:
DELETE [low_priority] [QUICK] [IGNORE]
TBL_NAME[.*] [, tbl_name[.*] ...]
From Table_references
[WHERE Where_definition]
Example
DELETE from Somelog
WHERE user = ' Jcole '
ORDER BY Timestamp_column
LIMIT 1;
Delete rows from many tables at the same time, and search using other tables:
DELETE T1, t2 from T1, T2, T3 WHERE t1.id=t2.id and t2.id=t3.id;
Or:
DELETE from T1, T2 USING T1, t2, T3 WHERE t1.id=t2.id and t2.id=t3.id;
TRUNCATE command differs from DELETE command
1, truncate on all kinds of tables, whether large or small are very fast. If a rollback command delete is revoked, the truncate is not revoked.
2, truncate is a DDL language, like all other DDL languages, he will be implicitly submitted, not to truncate use rollback command.
3, TRUNCATE will reset the high-level line and all indexes. When you fully browse the entire table and index, the table after the truncate operation is much faster than the table after the delete operation.
4, TRUNCATE cannot trigger any delete trigger.
5, can not give anyone the right to empty other people's table.
6, when the table is emptied after the table and table index is reset to the initial size, and delete is not.
7, can not empty the parent table.