MySQL Forums
Forum List  »  Triggers

before delete trigger to make backup of deleted data
Posted by: John Simons
Date: May 10, 2006 11:48AM

I had a relatively simple question. Let's assume I have the following tables...

create table hello (
x varchar(30),
y varchar(30),
z int);

I've created a duplicate table
create table hello_deleted_data (
x varchar(30),
y varchar(30),
z int);


"hello" is my main table. But when a user deletes a row, I want to store it in "hello_deleted_data" so I can retrieve deleted data if it was deleted erroneously (and then purge it later).

Logically this seems like I can put something in a "before delete" trigger, but am unable to derive the proper syntax from the examples I've seen. Could someone help me out?

create trigger hellox before delete on hello
insert into hello_deleted_data (x,y,z)
values (???.x, ???.y, ???.z); <-- ??

Much appreciated,
John Simons



Edited 1 time(s). Last edit at 05/10/2006 11:49AM by John Simons.

Options: ReplyQuote


Subject
Views
Written By
Posted
before delete trigger to make backup of deleted data
17122
May 10, 2006 11:48AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.