Untuk menghapus semua isi tabel dari database sekaligus formatnya

delete from namatabel

contoh saya memiliki database bernama fokus dan tabel ServiceTransaction. Login ke MySQL/MariaDB anda

mysql -u root -p fokus

sesuaikan dengan username, password dan nama database anda.
-u root : username root
-p : nanti anda diminta mengetikkan password
fokus : nama database

coba kita hitung jumlah data di tabel ServiceTransaction

count() from ServiceTransaction;

output

+----------+
| count(*) |
+----------+
|       61 |
+----------+
1 row in set (0.00 sec)

sekarang mari kita hapus sekaligus

delete from ServiceTransaction;

output

Query OK, 61 rows affected (0.12 sec)

mari kita cek lagi jumlah baris di ServiceTransaction

MariaDB [fokus]> select count(*) from ServiceTransaction;
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.00 sec)

mysql delete all data from table

Leave a comment

Your email address will not be published. Required fields are marked *