0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SQL文のDELETEで全件削除とTRUNCATEの違い

Posted at

DELETEとTRUNCATEの違いをメモ

DELETE TRUNCATE
削除スピード 遅い 速い
削除条件 可能(WHERE句) 不可能(全件削除)
SQLの種類 データ操作言語(DML:Data Manipulation Language) データ定義言語(DDL:Data Definition Language)
権限 DELETE権限 DROP権限
注意点 処理を確定するためにはCOMMITが必要でROLLBACKで戻すことも可能 実行前に暗黙的にCOMMITがかかる。実行後にCOMMITは不要でROLLBACKで戻せない

DELETE文

DELETE FROM テーブル名;

TRUNCATE文

TRUNCATE TABLE テーブル名;
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?