By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,709 Members | 2,153 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,709 IT Pros & Developers. It's quick & easy.

I need help in MySQL cascade on delete in MyISAM?

P: n/a
Hi

I have MyISAM tables

When I'm deleting parent I want to delete children in the same time.

How can I do It? What are possibilities?

Thanks
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
saracen44 wrote:
I have MyISAM tables
When I'm deleting parent I want to delete children in the same time.
How can I do It? What are possibilities?


As far as I have read, referential constraints are not enforced in
MyISAM tables at all, so cascading referential integrity probably
doesn't work for that table type either.

Bill K.
Jul 20 '05 #2

P: n/a
> As far as I have read, referential constraints are not enforced in
MyISAM tables at all, so cascading referential integrity probably
doesn't work for that table type either.

Bill K.


So how can I solve this problem??

I wont to delete parent with children in the same time.

How can I connect them to make that possible?

Writing script to check if parent has child then if child has a grandchidren
and so on.... and deleting them from the end is very time consuming when
executing by client.

How can I sole it?

Could you just write me some hints.

I will be very grateful

Regards

Maciek D

Jul 20 '05 #3

P: n/a
saracen44 wrote:
As far as I have read, referential constraints are not enforced in
MyISAM tables at all, so cascading referential integrity probably
doesn't work for that table type either.


So how can I solve this problem??
I wont to delete parent with children in the same time.
How can I connect them to make that possible?


The simplest way to solve this is to change your tables to InnoDB
tables, which do enforce referential integrity and cascading

Read the following web pages:
http://dev.mysql.com/doc/mysql/en/Co...to_InnoDB.html
http://dev.mysql.com/doc/mysql/en/In...nstraints.html

Another way to try to solve this, if you are using MySQL 4.0 or later,
is to try using the multi-table DELETE syntax.
See http://dev.mysql.com/doc/mysql/en/DELETE.html.

If you have a requirement to run cascading DELETEs over many referencing
tables, this could become laborious to construct the correct SQL. You
might forget to include one of the dependent tables.

If you aren't using MySQL 4.0, then you can't use the multi-table DELETE
syntax.

I think it would be easier to convert your database to InnoDB, and then
you could rely on cascading referential integrity constraints.

Regards,
Bill K.
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.