การลบและแก้ไข trigger

การสร้างและปรับแต่ง Trigger ใน SQL Server

Florin Angelescu

Instructor

การลบ trigger ของตารางและ view

DROP TRIGGER PreventNewDiscounts;

ตาราง

การสร้างและปรับแต่ง Trigger ใน SQL Server

การลบ trigger ของฐานข้อมูล

DROP TRIGGER PreventNewDiscounts;
DROP TRIGGER PreventViewsModifications
ON DATABASE;

ตาราง

ฐานข้อมูล

การสร้างและปรับแต่ง Trigger ใน SQL Server

การลบ trigger ของเซิร์ฟเวอร์

DROP TRIGGER PreventNewDiscounts;
DROP TRIGGER PreventViewsModifications
ON DATABASE;
DROP TRIGGER DisallowLinkedServers
ON ALL SERVER;

ตาราง

ฐานข้อมูล

เซิร์ฟเวอร์

การสร้างและปรับแต่ง Trigger ใน SQL Server

การปิดใช้งาน trigger

DISABLE TRIGGER PreventNewDiscounts
ON Discounts;
DISABLE TRIGGER PreventViewsModifications
ON DATABASE;
DISABLE TRIGGER DisallowLinkedServers
ON ALL SERVER;

ตาราง

ฐานข้อมูล

เซิร์ฟเวอร์

การสร้างและปรับแต่ง Trigger ใน SQL Server

การเปิดใช้งาน trigger

ENABLE TRIGGER PreventNewDiscounts
ON Discounts;
ENABLE TRIGGER PreventViewsModifications
ON DATABASE;
ENABLE TRIGGER DisallowLinkedServers
ON ALL SERVER;

ตาราง

ฐานข้อมูล

เซิร์ฟเวอร์

การสร้างและปรับแต่ง Trigger ใน SQL Server

การแก้ไข trigger

CREATE TRIGGER PreventDiscountsDelete
ON Discounts
INSTEAD OF DELETE
AS
    PRINT 'You are not allowed to data from the Discounts table.';
DROP TRIGGER PreventDiscountsDelete;
CREATE TRIGGER PreventDiscountsDelete
ON Discounts
INSTEAD OF DELETE
AS
    PRINT 'You are not allowed to remove data from the Discounts table.';
การสร้างและปรับแต่ง Trigger ใน SQL Server

การแก้ไข trigger

CREATE TRIGGER PreventDiscountsDelete
ON Discounts
INSTEAD OF DELETE
AS
    PRINT 'You are not allowed to data from the Discounts table.';
ALTER TRIGGER PreventDiscountsDelete
ON Discounts
INSTEAD OF DELETE
AS
    PRINT 'You are not allowed to remove data from the Discounts table.';
การสร้างและปรับแต่ง Trigger ใน SQL Server

มาฝึกกันเถอะ!

การสร้างและปรับแต่ง Trigger ใน SQL Server

Preparing Video For Download...