Change table engine to MyISAM
ALTER TABLE `tableName` ENGINE = MYISAM
Change table engine to innodb
ALTER TABLE `tableName` ENGINE = innodb
How to create table to MYISAM
mysql> CREATE TABLE table2 (col1 INT, col2 CHAR(30)) ENGINE = MYISAM;
Features of MYISAM and INNODB
ALTER TABLE `tableName` ENGINE = MYISAM
Change table engine to innodb
ALTER TABLE `tableName` ENGINE = innodb
How to create table to MYISAM
mysql> CREATE TABLE table2 (col1 INT, col2 CHAR(30)) ENGINE = MYISAM;
Features of MYISAM and INNODB
Feature
|
InnoDB
|
MyISAM
|
Storage limits
|
64TB
|
256TB
|
Transactions
|
Yes
|
No
|
Locking granularity
|
Row
|
Table
|
MVCC
|
Yes
|
No
|
B-tree indexes
|
Yes
|
Yes
|
Clustered indexes
|
Yes
|
No
|
Data caches
|
Yes
|
No
|
MyISAM
Innodb
- MyISAM doesn’t support foreign key constraints or transactions, which are essential for data integrity. Hence we call MySQL with MYISAM is DBMS
- MYISAM not supports transaction. You cannot commit and rollback with MYISAM.
- MYISAM supports Table-level Locking : In addition, the whole table is locked whenever a record is inserted or updated; this causes a detrimental effect on performance as usage grows.So no other session can perform a SELECT or a DML operation on the table.
- MyISAM stores its tables, data and indexes in diskspace using separate three different files. (tablename.FRM, tablename.MYD, tablename.MYI)
- Support Full-text indexing.When use "select" statement, gives faster results as compare to Innodb. so you can use MyISAM, if the table is more static with lots of select and less update and delete.
- When read, a MyISAM table's indexes can be read once from the .MYI file and loaded in the MyISAM Key Cache (as sized by key_buffer_size).ALTER TABLE mytable ROW_FORMAT=Fixed;
- We can you make a MyISAM table's .MYD faster with this
- An .frm file stores the table format.
- The data file has an .MYD (MYData) extension.
- The index file has an .MYI (MYIndex) extension.
- All numeric key values are stored with the high byte first to permit better index compression.
Innodb
- It is an ACID compliant storage engine.
- It supports row-level locking, crash recovery and multi-version concurrency control.
- Foreign key constraints : If you need the database to enforce foreign key constraints, or you need the database to support transactions (i.e. changes made by two or more DML operations handled as single unit of work, with all of the changes either applied, or all the changes reverted) then you would choose the InnoDB.
- Used for Secure Transactions section just like dealing with some payment systems.
Notes:
- When you create an InnoDB table, MySQL creates a .frm file in a database directory under the MySQL data directory. It also create an .ibd file.
- .idb files contain a single table and associated index data
ACID (Atomicity, Consistency, Isolation, and Durability)
Atomicity: Atomicity requires that each transaction be "all or nothing".
When a transaction makes multiple changes to the database, either all the changes succeed when the transaction is committed, or all the changes are undone when the transaction is rolled back.
Consistency: The database remains in a consistent state at all times.
After each commit or rollback. While transaction data are in consistent mode. i.e If related data is being updated across multiple tables, queries see either all old values or all new values, not a mix of old and new values.
Isolation: Isolation requires that multiple transactions occurring at the same time not impact each other's execution. i.e Transactions are protected from each other while they are in progress.
Durability: Once a commit operation succeeds , results of transactions are durable.
It is property that ensures transactions are saved permanently and do not accidentally disappear or get erased, even during a database crash.
No comments:
Post a Comment