Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

MySQL:Memotong Tabel vs Menghapus Dari Tabel

HAPUS DARI TABEL

1. DELETE is a DML Command.
2. DELETE statement is executed using a row lock, each row in the table is locked for deletion.
3. We can specify filters in where clause
4. It deletes specified data if where condition exists.
5. Delete activates a trigger because the operation are logged individually.
6. Slower than truncate because, it keeps logs.
7. Rollback is possible.
8. LIMIT clause can also be used to set a limit on the number of rows to be deleted.
9. ORDER BY clause can be used in DELETE statement. In this case, the rows are deleted in the specified order.

TRUNCATE TABEL

1. TRUNCATE is a DDL command.
2. TRUNCATE TABLE always locks the table and page but not each row.
3. Cannot use Where Condition.
4. It Removes all the data reset the auto increment number.
5. TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions.
6. Faster in performance wise, because it doesn't keep any logs.
7. Rollback is possible.
8. Cannot use LIMIT and ORDER BY.

HAPUS dan POTONGKAH keduanya dapat digulung kembali saat digunakan dengan TRANSACTION. Jika ada kunci utama dengan kenaikan otomatis, truncate akan mengatur ulang penghitung.




  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Tidak dapat terhubung ke MySQL di Mac -- file mysql.sock hilang

  2. Bagaimana cara memilih satu baris secara acak dengan mempertimbangkan bobot?

  3. bagaimana saya bisa mengekspor database mysql menggunakan ssh?

  4. cara mengatasi ERROR 1045 (28000):Akses ditolak untuk pengguna 'ODBC'@'localhost' (menggunakan kata sandi:TIDAK) secara permanen

  5. KIRI JOIN pesanan dan batas