我可以在ONE数据库中使用InnoDB和MyISAM表吗?

时间:2021-01-11 07:34:16

Obviously both have their benefits. MyISAM is fast but may get currupted easily, InnoDB is slow but is more stable thanks to transactions and foreign keys. So it could be good to mix both engines in one database. If that's possible?

显然两者都有其好处。 MyISAM很快但可能很容易被破坏,InnoDB很慢但由于交易和外键更稳定。因此,将两个引擎混合在一个数据库中可能会很好。如果那可能吗?

3 个解决方案

#1


17  

REMEMBER! It's OK to mix table types in the same database! In fact it's recommended and frequently required. However, it is important to note that if you are having performance issues when joining the two types, try converting one to the other and see if that fixes it. This issue does not happen often but it has been reported.

记得!可以在同一个数据库中混合表类型!事实上,它是推荐的,经常需要。但是,请务必注意,如果在加入这两种类型时遇到性能问题,请尝试将其中一种转换为另一种,然后查看是否可以修复它。这个问题并不经常发生,但据报道。

Taken from MySQL - InnoDB vs MyISAM

取自MySQL - InnoDB vs MyISAM

#2


5  

Sure, that's possible.

当然,那是可能的。

CREATE TABLE MyISAM_tbl(
    ....
)ENGINE=MyISAM;

CREATE TABLE InnoDB_tbl (
    ....
)ENGINE=InnoDB;

I do this all the time, because I prefer InnoDB for the FKs, but I sometimes need MyISAM for the full-text search. Never had a problem.

我一直这样做,因为我更喜欢InnoDB用于FK,但我有时需要MyISAM进行全文搜索。没问题。

#3


1  

In a word yes. (CREATE TABLE lets you specify the engine type.)

总之是的。 (CREATE TABLE允许您指定引擎类型。)

However, you have to take care when you're querying across multiple table types. (For example you can't take advantage of foreign keys on MyISAM and you can't commit a transaction that affects MyISAM tables, etc.)

但是,在查询多个表类型时必须小心。 (例如,您无法利用MyISAM上的外键,也无法提交影响MyISAM表的事务等)

In essence, I suspect this might not be the best approach to take. (Unless you only need transactions for a defined set of tables that are segmented from the remainder of your database and InnoDB is too slow, getting a faster database server may well transpire to be less painful.)

从本质上讲,我怀疑这可能不是最好的方法。 (除非您只需要从数据库的其余部分分割的一组已定义的表的事务,并且InnoDB太慢,否则获得更快的数据库服务器可能会减少痛苦。)

#1


17  

REMEMBER! It's OK to mix table types in the same database! In fact it's recommended and frequently required. However, it is important to note that if you are having performance issues when joining the two types, try converting one to the other and see if that fixes it. This issue does not happen often but it has been reported.

记得!可以在同一个数据库中混合表类型!事实上,它是推荐的,经常需要。但是,请务必注意,如果在加入这两种类型时遇到性能问题,请尝试将其中一种转换为另一种,然后查看是否可以修复它。这个问题并不经常发生,但据报道。

Taken from MySQL - InnoDB vs MyISAM

取自MySQL - InnoDB vs MyISAM

#2


5  

Sure, that's possible.

当然,那是可能的。

CREATE TABLE MyISAM_tbl(
    ....
)ENGINE=MyISAM;

CREATE TABLE InnoDB_tbl (
    ....
)ENGINE=InnoDB;

I do this all the time, because I prefer InnoDB for the FKs, but I sometimes need MyISAM for the full-text search. Never had a problem.

我一直这样做,因为我更喜欢InnoDB用于FK,但我有时需要MyISAM进行全文搜索。没问题。

#3


1  

In a word yes. (CREATE TABLE lets you specify the engine type.)

总之是的。 (CREATE TABLE允许您指定引擎类型。)

However, you have to take care when you're querying across multiple table types. (For example you can't take advantage of foreign keys on MyISAM and you can't commit a transaction that affects MyISAM tables, etc.)

但是,在查询多个表类型时必须小心。 (例如,您无法利用MyISAM上的外键,也无法提交影响MyISAM表的事务等)

In essence, I suspect this might not be the best approach to take. (Unless you only need transactions for a defined set of tables that are segmented from the remainder of your database and InnoDB is too slow, getting a faster database server may well transpire to be less painful.)

从本质上讲,我怀疑这可能不是最好的方法。 (除非您只需要从数据库的其余部分分割的一组已定义的表的事务,并且InnoDB太慢,否则获得更快的数据库服务器可能会减少痛苦。)