Skip to main content

MySQL - DELETE

什麼是DELETE

DELETE 是 SQL 中用於刪除表中數據的語句

範例

WHERE 條件式切記一定要加, 不然你會把所有的資料刪除...

INPUT:
SELECT name
FROM users;

OUTPUT:
| name |
|--------|
| Jasper |
| David |
| Alice |

INPUT:
DELETE FROM users
WHERE name='Jasper'

OUTPUT:
| name |
|-------|
| David |
| Alice |

補充

如果你想要將整張表的資料刪除, 請不要使用DELETE, 善用TRUNCATE