Category Archives: My SQL

MEMORY Storage Engine

The MEMORY storage engine creates tables with contents that are stored in memory. Formerly, these were known as HEAP tables. MEMORY is the preferred term, although HEAP remains supported for backward compatibility.The MEMORY storage engine associates each table with one disk file. The file name begins with the table name and has an extension of .frm to indicate that it stores the table definition.ExampleCREATE TABLE t (i INT) ENGINE = MEMORY;

As indicated by the engine name, MEMORY tables are stored in memory. They use hash indexes by default, which makes them very fast, and very useful for creating temporary tables. However, when the server shuts down, all rows stored in MEMORY tables are lost. The tables themselves continue to exist because their definitions are stored in .frm files on disk, but they are empty when the server restarts.

MEMORY tables can have up to 64 indexes per table

MEMORY tables can have up to 16 columns per index

MEMORY tables can have maximum key length of 3072 bytes.

Space for MEMORY tables is allocated in small blocks. Tables use 100% dynamic hashing for inserts.

The MEMORY storage engine supports both HASH and BTREE indexes. You can specify one or the other for a given index by adding a USING clause

MEMORY tables can have nonunique keys.

Columns that are indexed can contain NULL values.

MEMORY tables use a fixed-length row-storage format. Variable-length types such as VARCHAR are stored using a fixed length.

MEMORY tables cannot contain BLOB or TEXT columns.

MEMORY includes support for AUTO_INCREMENT columns.

The server needs sufficient memory to maintain all MEMORY tables that are in use at the same time.

MERGE Storage Engine

The MERGE storage engine is also known as the MRG_MyISAM engine and it is a collection of identical MyISAM tables that can be used as one. “Identical” means that all tables have identical column and index information. You cannot merge MyISAM tables in which the columns are listed in a different order, do not have exactly the same columns, or have the indexes in different order. However, any or all of the MyISAM tables can be compressed withWhen you create a MERGE table, MySQL creates two files on disk. The files have names that begin with the table name and have an extension to indicate the file type. An .frm file stores the table format, and an .MRG file contains the names of the underlying MyISAM tables that should be used as one. The tables do not have to be in the same database as the MERGE table.You can use SELECT, DELETE, UPDATE, and INSERT on MERGE tables. You must have SELECT, DELETE, and UPDATE privileges on the MyISAM tables that you map to a MERGE table.

Use of DROP TABLE with a MERGE table drops only the MERGE specification. The underlying tables are not affected.

We can create MERGE table using the option UNION={list-of-tables} that indicates which MyISAM tables to use. You can optionally specify an INSERT_METHOD option to control how inserts into the MERGE table take place. Use a value of FIRST or LAST to cause inserts to be made in the first or last underlying table, respectively. If you specify no INSERT_METHOD option or if you specify it with a value of NO, inserts into the MERGE table are not permitted and attempts to do so result in an error.



Here blog1,blog2 should have identical column and index information .

InnoDB Storage Engine

InnoDB is a transaction-safe storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data. It stores user data in clustered indexes to reduce I/O for common queries based on primary keys. To maintain data integrity, InnoDB also supports FOREIGN KEY referential-integrity constraints.InnoDB has been designed for maximum performance when processing large data volumes. Its CPU efficiency is probably not matched by any other disk-based relational database engine.The InnoDB storage engine maintains its own buffer pool for caching data and indexes in main memory. InnoDB stores its tables and indexes in a tablespace, which may consist of several files .

InnoDB is used in production at numerous large database sites requiring high performance.

MyISAM Storage Engine

MyISAM is the default storage engine. It is based on the older ISAM storage engine with new extensions.
It manages nontransactional tables. It provides high-speed storage and retrieval, as well as fulltext searching capabilities
Each MyISAM table is stored on disk in three files. The files have names that begin with the table name and have an extension to indicate the file type. An .frm file stores the table format.
The data file has an .MYD (MYData) extension. The index file has an .MYI (MYIndex) extension.

Storage engine should be mentioned when we careate tables


Normally, it is unnecessary to use ENGINE to specify the MyISAM storage engine. MyISAM is the default engine unless the default has been changed. To ensure that MyISAM is used in situations where the default might have been changed, include the ENGINE option explicitly.

You can check or repair MyISAM tables with the mysqlcheck client or myisamchk utility.

All data values are stored with the low byte first. This makes the data machine and operating system independent.

All numeric key values are stored with the high byte first to permit better index compression.

Large files (up to 63-bit file length) are supported on file systems and operating systems that support large files.

There is a limit of 232  rows in a MyISAM table. If you build MySQL with the

The maximum number of indexes per MyISAM table is 64.

The maximum number of columns per index is 16.

The maximum key length is 1000 bytes.

When rows are inserted in sorted order ,the index tree is split so that the high node only contains one key. This improves space utilization in the index tree.

MyISAM supports concurrent inserts:

You can put the data file and index file in different directories on different physical devices

BLOB and TEXT columns can be indexed.

NULL values are permitted in indexed columns.

There is a flag in the MyISAM index file that indicates whether the table was closed correctly.

The sum of the lengths of the VARCHAR and CHAR columns in a table may be up to 64KB.


Storage Engines

A storage engine (database engine) is the underlying software component that a database management system (DBMS) uses to create, read, update and delete (CRUD) data from a database. Many of the modern DBMS support multiple database engines within the same database.Below given are the different storage engines that MySQL supports .