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

发布于 2024-08-16 08:54:14 字数 93 浏览 11 评论 0原文

显然两者都有各自的优点。 MyISAM 速度快,但可能容易崩溃,InnoDB 速度慢,但由于事务和外键而更稳定。因此,将两种引擎混合在一个数据库中可能会很好。如果可以的话?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

空‖城人不在 2024-08-23 08:54:15

记住!在同一个数据库中混合表类型是可以的!事实上,这是推荐的并且经常需要的。但是,请务必注意,如果您在加入这两种类型时遇到性能问题,请尝试将一种类型转换为另一种类型,看看是否可以解决问题。此问题并不经常发生,但已报告过。

摘自 MySQL - InnoDB 与 MyISAM

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

莫言歌 2024-08-23 08:54:15

当然,这是可能的。

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

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

我一直这样做,因为我更喜欢 InnoDB 作为 FK,但有时我需要 MyISAM 来进行全文搜索。从来没有遇到过问题。

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.

你爱我像她 2024-08-23 08:54:15

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

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

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

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

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.)

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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文