Mencegah penghapusan tabel
Fresh Fruit Delivery ingin mencegah karyawan regulernya menghapus tabel dari database.
Latihan ini merupakan bagian dari kursus
Membangun dan Mengoptimalkan Trigger di SQL Server
Instruksi latihan
- Buat pemicu baru,
PreventTableDeletion, untuk mencegah penghapusan tabel. - Pemicu harus melakukan rollback pada pernyataan pemicu, sehingga penghapusan tidak terjadi.
Latihan interaktif langsung praktik
Cobalah latihan ini dengan melengkapi kode contoh ini.
-- Add a trigger to disable the removal of tables
CREATE TRIGGER ___
ON DATABASE
FOR ___
AS
RAISERROR ('You are not allowed to remove tables from this database.', 16, 1);
-- Revert the statement that removes the table
___;