共計 2076 個字符,預計需要花費 6 分鐘才能閱讀完成。
InnoDB 和 MyISAM 的區別是什么,相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。
InnoDB 和 MyISAM 是許多人在使用 MySQL 時最常用的兩個表類型,這兩個表類型各有優劣,視具體應用而定。以前 MySQL 默認的存儲引擎是 MYISAM,從 5.5.5 之后就改用 InnoDB 了。它們的基本的差別為:MyISAM 類型不支持事務處理等高級處理,而 InnoDB 類型支持。MyISAM 類型的表強調的是性能,其執行數度比 InnoDB 類型更快,但是不提供事務支持,而 InnoDB 提供事務支持已經外部鍵等高級數據庫功能。
MyIASM 是 IASM 表的新版本,有如下擴展:
middot; 二進制層次的可移植性。
middot;NULL 列索引。
middot; 對變長行比 ISAM 表有更少的碎片。
middot; 支持大文件。
middot; 更好的索引壓縮。
middot; 更好的鍵嗎統計分布。
middot; 更好和更快的 auto_increment 處理。
以下是一些細節和具體實現的差別:
◆1.InnoDB 不支持 FULLTEXT 類型的索引。
◆2.InnoDB 中不保存表的具體行數,也就是說,執行 select count(*) from table 時,InnoDB 要掃描一遍整個表來計算有多少行,但是 MyISAM 只要簡單的讀出保存好的行數即可。注意的是,當 count(*) 語句包含 where 條件時,兩種表的操作是一樣的。
◆3. 對于 AUTO_INCREMENT 類型的字段,InnoDB 中必須包含只有該字段的索引,但是在 MyISAM 表中,可以和其他字段一起建立聯合索引。
◆4.DELETE FROM table 時,InnoDB 不會重新建立表,而是一行一行的刪除。
◆5.LOAD TABLE FROM MASTER 操作對 InnoDB 是不起作用的,解決方法是首先把 InnoDB 表改成 MyISAM 表,導入數據后再改成 InnoDB 表,但是對于使用的額外的 InnoDB 特性(例如外鍵)的表不適用。
在高性能 MYSQL 上還說默認 MYISAM,其實要看那個版本,我現在的默認就是 InnoDB,手冊上是這么說的:
InnoDB is a high-reliability and high-performance storage engine for MySQL. Starting with MySQL 5.5, it is the default MySQL storage engine. Key advantages of InnoDB include:
Its design follows the ACID model, with transactions featuring commit, rollback, and crash-recovery capabilities to protect user data.
Row-level locking and Oracle-style consistent reads increase multi-user concurrency and performance.
InnoDB tables arrange your data on disk to optimize common queries based on primary keys. Each InnoDB table has a primary key index called the clustered index that organizes the data to minimize I/O for primary key lookups.
To maintain data integrity, InnoDB also supports FOREIGN KEY referential-integrity constraints.
You can freely mix InnoDB tables with tables from other MySQL storage engines, even within the same statement. For example, you can use a join operation to combine data from InnoDB and MEMORY tables in a single query.
To determine whether your server supports InnoDB use the SHOW ENGINES statement.
Before MySQL 5.5.5, MyISAM is the default storage engine. (The default was changed to InnoDB in MySQL 5.5.5.) MyISAM is based on the older (and no longer available) ISAM storage engine but has many useful extensions.
Table 13.10. MyISAM Storage Engine Features
看完上述內容,你們掌握 InnoDB 和 MyISAM 的區別是什么的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注丸趣 TV 行業資訊頻道,感謝各位的閱讀!