MySQL storage engines


Home - Tutorials - MySQL

In this article I will summarise the MySQL storage engines (table types) to help you select the right one for your needs.

Tutorial info:


Name:MySQL storage engines
Total steps:1
Category:MySQL
Date:2008-04-02
Level:Beginner
Product:See complete product
Viewed:839

Bookmark MySQL storage engines



AddThis Social Bookmark Button

Step 1 - MySQL storage engines


MySQL storage engines

When you create a new table in MySQL then there is the possibility to define the table type or storage engine at the end of your table definition. This is not a mandatory part of your table definition. If you don't define an engine then the default one will be used. Later you can change the storage engine by ALTER TABLE command.

Here is an example how to create a table specifying a storage engine:

Code:
  1. CREATE TABLE demo
  2. (
  3. username VARCHAR(50) NOT NULL,
  4. age SMALLINT NOT NULL
  5. ) ENGINE=MyISAM;

Instead of ENGINE keyword you can also use TYPE, however the preferred one is the ENGINE as the TYPE is only for backward compatibility. 

MySQL Storage engines 

In MySQL you have the possibility to select from the following storage engines:

In older MySQL version the BDB and ISAM table types were also available but in the new versions they are not more supported. Besides this in MySQL 6 there will be a new table type called Falcon.

In this article I will focus only on the most commonly used types, listed above.

MyISAM 

MyISAM is the default storage engine in MySQL. It is the improved replacement of the old ISAM table type. Using MyISAM storage engine every table is stored in 3 different files:

  1. .frm file which stores the table structure
  2. .MYD file, which stores the table data
  3. .MYI file which is the index file

MyISAM storage engine is optimized for speed and supports extensive indexing. You can index BLOB and TEXT and also supports FULLTEXT indexes.

However MyISAM tables do not supports foreign key constraint and row level locking.

InnoDB

InnoDB is a transaction-safe storage engine in MySQL. Table data are managed by the InnoDB tablespace. These table type supports foreign key constraints and row level locking as well. However FULLTEXT indexes are not supported.

MERGE 

The MERGE storage engine is a bit special. In this case the data are not stored in the MERGE table, but in the MyISAM tables from which the virtual MERGE table was made up.

MEMORY 

In case of MEMORY storage engine the data are stored in the memory and are available only as long as the MySQL server is available. The MEMORY tables are very fast and so they are ideal for temporary tables.

I hope this small introduction helps you a bit to decide which storage engine to select for your project. 

 






Tags: mysql storage engine, storage engine, mysql table type, table type, mysql, storage, engine,

MySQL storage engines - Table of contents
Step 1 - MySQL storage engines

F1 Site Family
AJAX F1
CSS F1
Database F1
Forex F1
Flash F1
HTML F1
JavaScript F1
PhotoShop F1
PHP F1
 

 
MaxTutorial
Monthly mortgage payment calculator
WebFormGenerator
Forex mini accounts

Total time: 0.0267