How to stop a row from being deleted using trigger?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

How to stop a row from being deleted using trigger?

Post by raghavan20 »

Is it possible to detect when a row is tried to be deleted and stop it from deleting?

let's take a simple row:
name id
rag 4

I do not want this row deleted somehow using trigger or ?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Which SQL DBMS are you using? Most have a TRIGGER INSTEAD OF DELETE construct...
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

timvw wrote:Which SQL DBMS are you using? Most have a TRIGGER INSTEAD OF DELETE construct...
I am working on mysql.
I do not want anyone to accidentally delete some important rows in tables which are meant to be there all the time. I want to stop people from deleting it somehow.

timvw, do you know any good editor for triggers, because navicat or query browser do not support triggers properly. Use of 'show triggers' does give us only the body of the trigger which is not really so useful.

Thanks
Post Reply