MySQL
  Home arrow MySQL arrow Page 11 - Storage Engine (Table Types)
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MYSQL

Storage Engine (Table Types)
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 46
    2004-08-02

    Table of Contents:
  • Storage Engine (Table Types)
  • Locking
  • Multi-Version Concurrency Control
  • Transactions
  • Bene
  • Deadlocks
  • Transactions in MySQL
  • Selecting the Right Engine
  • Practical Examples
  • Table Conversions
  • The Storage Engines
  • MyISAM Tables
  • Compressed MyISAM Tables
  • InnoDB Tables
  • Heap (In-Memory) Tables

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Storage Engine (Table Types) - The Storage Engines


    (Page 11 of 15 )

    Now it’s time to look at each of MySQL’s storage engines in more detail. Table 2-3 summarizes some of the high-level characteristics of the handlers. The following sections provide some basic highlights and background about each table handler as well as any unusual characteristics and interesting features.

    Before going further, it’s worth noting that this isn’t an exhaustive discussion of MySQL’s storage engines. We assume that you’ve read (or at least know where to find) the information in the MySQL Reference Manual.

    Table 2-5: Storage Engine features in MySQL

    Attribute

    MyISAM

    Heap

    BDB

    InnoDB

    Transactions

    No

    No

    Yes

    Yes

    Lock granularity

    Table

    Table

    Page (8 KB)

    Row

    Storage

    Split files

    In-memory

    Single file per table

    Tablespace(s)

    Isolation levels

    None

    None

    Read committed

    All

    Portable format

    Yes

    N/A

    No

    Yes

    Referential integrity

    No

    No

    No

    Yes

    Primary key with data

    No

    No

    Yes

    Yes

    MySQL caches data records

    No

    Yes

    Yes

    Yes

    Availability

    All versions

    All versions

    MySQL-Max

    All Versions*

    *Prior to MySQL 4.0, InnoDB was available in MySQL-Max only.

    Most of MySQL’s disk-based tables have some basic things in common. Each database in MySQL is simply a subdirectory of MySQL’s data directory in the underlying filesystem.* Whenever you create a table, MySQL stores the table definition in a .frm file with the same name as the table. Thus, when you create a table named MyTable, MySQL stores the table definition in MyTable.frm.

    * In MySQL 5.0, the term “database” will likely morph into “schema.”

    To determine the type of a table, use the SHOW TABLE STATUS command. For example, to examine the user table in the mysql database, you execute the following:

    mysql> SHOW TABLE STATUS LIKE 'user' \G

    ****************** 1. row ***************************
    Name: user
    Type: MyISAM
    Row_format: Dynamic
    Rows: 6
    Avg_row_length: 59
    Data_length: 356
    Max_data_length: 4294967295
    Index_length: 2048
    Data_free: 0
    Auto_increment: NULL
    Create_time: 2002-01-24 18:07:17
    Update_time: 2002-01-24 21:56:29
    Check_time: NULL
    Create_options:
    Comment: Users and global privileges
    1 row in set (0.06 sec)

    Notice that it’s a MyISAM table. You might also notice a lot of other information and statistics in the output. Let’s briefly look at what each line means:

    Name

    The table’s name.

    Type

    The table’s type. Again, in some versions of MySQL, this may say “Engine” rather than “Type.”

    Row_format

    Dynamic, Fixed, or Compressed. Dynamic rows vary in length because they contain variable-length fields such as VARCHAR or BLOB. Fixed rows, which are always the same size, are made up of fields that don’t vary in length, such as CHAR and INTEGER. Compressed rows exist only in compressed tables (see the later section “Compressed MyISAM”).

    Rows

    The number of rows in the table. For non-transactional tables, this number is always accurate. For transactional tables, it is usually an estimate.

    Avg_row_length

    How many bytes the average row contains.

    Data_length

    How much data (in bytes) the entire table contains.

    Max_data_length

    The maximum amount of data this table can hold. In a MyISAM table with dynamic (variable length) rows, the index file for a table (tablename.MYI) stores row locations using 32-bit pointers into the data file (tablename.MYD). That means it can address only up to 4 GB of space by default. See the next section, “MyISAM Tables” for more details. For MyISAM tables with fixed-length rows, the limit is just under 4.3 billion rows.

    Index_length

    How much space is consumed by index data.

    Data_free

    The amount of space that has been allocated but is currently unused.

    Auto_increment

    The next AUTO_INCREMENT value.

    Create_time

    When the table was first created.

    Update_time

    When data in the table last changed.

    Check_time

    When the table was last checked using CHECK TABLE or myisamchk.

    Create_options

    Any other options that were specified when the table was created.

    Comment

    The comments, if any, that were set when the table was created.

    Buy the book!If you've enjoyed what you've seen here, or to get more information, click on the "Buy the book!" graphic. Pick up a copy today!

    Visit the O'Reilly Network http://www.oreillynet.com for more online content.

    More MySQL Articles
    More By O'Reilly Media


       · Where is figure 2-1?
       · We will look into this ASAP.
       · Fixed
       · I don't think, that this sentence is quite acurate"MVCC can be thought of as a...
     

       

    MYSQL ARTICLES

    - MySQL Table Prefix Changer Tool in PHP
    - Using the SIGNAL Statement for Error Handling
    - Error Handling Examples
    - Error Handling
    - Completing a Search Engine with MySQL and PH...
    - Paginating Result Sets for a Search Engine B...
    - Building a Search Engine with MySQL and PHP 5
    - Using Boolean Operators for Full Text and Bo...
    - PHP, MySQL and the PEAR Database
    - Working with PHP and MySQL
    - Getting PHP to Talk to MySQL
    - Creating an RSS Reader: the Reader
    - MySQL Security Overview
    - Creating the Admin Script for a PHP/MySQL Bl...
    - Creating the Blog Script for a PHP/MySQL Blo...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway