Subject | From Restriced to CASCADE on delete |
---|---|
Author | federonline |
Post date | 2008-01-15T23:46:02Z |
Greets.
I have three tables of data, two of which reference the primary key of
the third. Basically they are sensors that keep data for a short period.
We have one client that regularly moves the sensors about a building
and would prefer to delete/reload the sensor data. The issue is,
those two table are not set up to cascade the delete of the sensor to
the two data tables, so it is proving to be non-trivial for him.
There are views that use (are dependent on) those tables, so dropping
the tables and recreating becomes non-trivial as well (for me).
The metadata looks like this:
CREATE TABLE DATA (
MAC VARCHAR(32) NOT NULL,
DATETIME_STAMP TIMESTAMP default NULL);
/* Foreign key(s) */
ALTER TABLE DATA ADD CONSTRAINT FK_DATA_SENSOR_MAC
FOREIGN KEY (MAC) REFERENCES SENSOR(MAC)
ON UPDATE RESTRICT ON DELETE RESTRICT;
Is there an easy ALTER I can do to the FK to cascade my deletes??
Thanks in advance...
Kurt.
I have three tables of data, two of which reference the primary key of
the third. Basically they are sensors that keep data for a short period.
We have one client that regularly moves the sensors about a building
and would prefer to delete/reload the sensor data. The issue is,
those two table are not set up to cascade the delete of the sensor to
the two data tables, so it is proving to be non-trivial for him.
There are views that use (are dependent on) those tables, so dropping
the tables and recreating becomes non-trivial as well (for me).
The metadata looks like this:
CREATE TABLE DATA (
MAC VARCHAR(32) NOT NULL,
DATETIME_STAMP TIMESTAMP default NULL);
/* Foreign key(s) */
ALTER TABLE DATA ADD CONSTRAINT FK_DATA_SENSOR_MAC
FOREIGN KEY (MAC) REFERENCES SENSOR(MAC)
ON UPDATE RESTRICT ON DELETE RESTRICT;
Is there an easy ALTER I can do to the FK to cascade my deletes??
Thanks in advance...
Kurt.