开发者

Insert MyISAM key into a INNODB table

开发者 https://www.devze.com 2023-03-25 09:37 出处:网络
I\'m using this table structure for a \'toxi\' like TAGs system table TAGS +--------+-------------------+

I'm using this table structure for a 'toxi' like TAGs system

table TAGS

+--------+-------------------+
| alias  | isactive          |  varchar(55), tinyint(1)
+--------+-------------------+
| party  | 1                 |

Engine: MyISAM (because I use some 'autocomplete' using this table (field:alias) for 
a %xxx% search

table TAGREL

+-------------+-------------------+
| tags_alias  | productID         |  varchar(55), int(11)
+-------------+-------------------+
|   party     | 15                |

Engine: InnoDB (i dont need full search here)
This TAGREL table uses tags.alias as FK (on update cascade, on delete cascade)  and 
product id as FK (on update no action, on delete cascade)

I mean, the whole idea is that, when I update some tag name (or erase it) or even delete a product, the relation on the TAGREL is auto updated.

But I cant even ADD a record to TAGREL table, it says a foreign key on table TAGS error, even if the data I'm inserting is correct (a valid TAGS alias and a valid product ID)

I can't do this kind of thing on MySQL? The only solution (as I NEED the full search on 开发者_StackOverflowthe TAGS table) is to manually update the tagrel whenever I update some tag OR erase a product?

Thanks.


You cannot create foreign keys in InnoDB tables referencing MyISAM tables.

Foreign keys definitions are subject to the following conditions:

Both tables must be InnoDB tables and they must not be TEMPORARY tables.

http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html

So yes, you will have to manually enforce the constraints from your application code if you do not change the storage engine.

LIKE '%XXX%' searches are not fulltext; unless you actually specified a fulltext index and are using fulltext matching functions, you do not need to use the MyISAM engine.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号