Home » SQL » Keyword DROP TABLE dan TRUNCATE TABLE SQL : Fungsi dan Contohnya

Keyword DROP TABLE dan TRUNCATE TABLE SQL : Fungsi dan Contohnya

by Hanifah Nurbaeti
by Hanifah Nurbaeti

DROP TABLE

Perintah DROP TABLE digunakan untuk menghapus tabel dalam database.

SQL berikut menghapus tabel “Suppliers”:

Contoh

DROP TABLE Suppliers;

Catatan: Hati-hati sebelum menghapus tabel. Menghapus tabel mengakibatkan hilangnya semua informasi yang disimpan dalam tabel!

TRUNCATE TABLE

Perintah TRUNCATE TABLE digunakan untuk menghapus data di dalam tabel, tetapi tidak menghapus tabel itu sendiri.

SQL berikut memotong tabel “Shippers”:

Contoh

TRUNCATE TABLE Shippers;

You may also like