7 MySQL Table Types
As of MySQL Version 3.23.6, you can choose between three basic
table formats (ISAM
, HEAP
and MyISAM
). Newer
versions of MySQL support additional table types (InnoDB
,
or BDB
), depending on how you compile it. A database may contain
tables of different types.
When you create a new table, you can tell MySQL what type of table to create.
The default table type is usually MyISAM
.
MySQL will always create a `.frm' file to hold the table and column
definitions. The table's index and data will be stored in one or more other
files, depending on the table type.
If you try to use a table type that is not compiled-in or activated,
MySQL will instead create a table of type MyISAM
. This behaviour
is convenient when you want to copy tables between MySQL servers that
support different table types. (Perhaps your master server supports
transactional storage engines for increased safety, while the slave servers use
only non-transactional storage engines for greater speed.)
This automatic change of table types can be confusing for new MySQL users. We
plan to fix this by introducing warnings in the new client/server protocol in
version 4.1 and generating a warning when a table type is automatically changed.
You can convert tables between different types with the ALTER
TABLE
statement. See section 6.5.4 ALTER TABLE
Syntax.
Note that MySQL supports two different kinds of
tables: transaction-safe tables (InnoDB
and BDB
)
and not transaction-safe tables (HEAP
, ISAM
,
MERGE
, and MyISAM
).
Advantages of transaction-safe tables (TST):
-
Safer. Even if MySQL crashes or you get hardware problems, you
can get your data back, either by automatic recovery or from a backup
+ the transaction log.
-
You can combine many statements and accept these all in one go with
the
COMMIT
command.
-
You can execute
ROLLBACK
to ignore your changes (if you are not
running in auto-commit mode).
-
If an update fails, all your changes will be restored. (With NTST tables all
changes that have taken place are permanent)
-
Can provide better concurrency if the table gets many updates concurrently
with reads.
Note that to use InnoDB
tables you have to use at least the
innodb_data_file_path
startup option. See section 7.5.3 InnoDB Startup Options.
Advantages of not transaction-safe tables (NTST):
-
Much faster as there is no transaction overhead.
-
Will use less disk space as there is no overhead of transactions.
-
Will use less memory to do updates.
You can combine TST and NTST tables in the same statements to get the best
of both worlds.
Subsections
- 7.1
MyISAM
Tables
- 7.2
MERGE
Tables
- 7.3
ISAM
Tables
- 7.4
HEAP
Tables
- 7.5
InnoDB
Tables
- 7.5.1 InnoDB Tables Overview
- 7.5.2 InnoDB in MySQL Version 3.23
- 7.5.3 InnoDB Startup Options
- 7.5.4 Creating InnoDB Tablespace
- 7.5.5 Creating InnoDB Tables
- 7.5.6 Adding and Removing InnoDB Data and Log Files
- 7.5.7 Backing up and Recovering an InnoDB Database
- 7.5.8 Moving an InnoDB Database to Another Machine
- 7.5.9 InnoDB Transaction Model
- 7.5.10 Implementation of Multi-versioning
- 7.5.11 Table and Index Structures
- 7.5.12 File Space Management and Disk I/O
- 7.5.13 Error Handling
- 7.5.14 Restrictions on InnoDB Tables
- 7.5.15 InnoDB Change History
- 7.5.15.1 MySQL/InnoDB-4.0.14, July 22, 2003
- 7.5.15.2 MySQL/InnoDB-3.23.57, June 20, 2003
- 7.5.15.3 MySQL/InnoDB-4.0.13, May 20, 2003
- 7.5.15.4 MySQL/InnoDB-4.1.0, April 3, 2003
- 7.5.15.5 MySQL/InnoDB-3.23.56, March 17, 2003
- 7.5.15.6 MySQL/InnoDB-4.0.12, March 18, 2003
- 7.5.15.7 MySQL/InnoDB-4.0.11, February 25, 2003
- 7.5.15.8 MySQL/InnoDB-4.0.10, February 4, 2003
- 7.5.15.9 MySQL/InnoDB-3.23.55, January 24, 2003
- 7.5.15.10 MySQL/InnoDB-4.0.9, January 14, 2003
- 7.5.15.11 MySQL/InnoDB-4.0.8, January 7, 2003
- 7.5.15.12 MySQL/InnoDB-4.0.7, December 26, 2002
- 7.5.15.13 MySQL/InnoDB-4.0.6, December 19, 2002
- 7.5.15.14 MySQL/InnoDB-3.23.54, December 12, 2002
- 7.5.15.15 MySQL/InnoDB-4.0.5, November 18, 2002
- 7.5.15.16 MySQL/InnoDB-3.23.53, October 9, 2002
- 7.5.15.17 MySQL/InnoDB-4.0.4, October 2, 2002
- 7.5.15.18 MySQL/InnoDB-4.0.3, August 28, 2002
- 7.5.15.19 MySQL/InnoDB-3.23.52, August 16, 2002
- 7.5.15.20 MySQL/InnoDB-4.0.2, July 10, 2002
- 7.5.15.21 MySQL/InnoDB-3.23.51, June 12, 2002
- 7.5.15.22 MySQL/InnoDB-3.23.50, April 23, 2002
- 7.5.15.23 MySQL/InnoDB-3.23.49, February 17, 2002
- 7.5.15.24 MySQL/InnoDB-3.23.48, February 9, 2002
- 7.5.15.25 MySQL/InnoDB-3.23.47, December 28, 2001
- 7.5.15.26 MySQL/InnoDB-4.0.1, December 23, 2001
- 7.5.15.27 MySQL/InnoDB-3.23.46, November 30, 2001
- 7.5.15.28 MySQL/InnoDB-3.23.45, November 23, 2001
- 7.5.15.29 MySQL/InnoDB-3.23.44, November 2, 2001
- 7.5.15.30 MySQL/InnoDB-3.23.43, October 4, 2001
- 7.5.15.31 MySQL/InnoDB-3.23.42, September 9, 2001
- 7.5.15.32 MySQL/InnoDB-3.23.41, August 13, 2001
- 7.5.15.33 MySQL/InnoDB-3.23.40, July 16, 2001
- 7.5.15.34 MySQL/InnoDB-3.23.39, June 13, 2001
- 7.5.15.35 MySQL/InnoDB-3.23.38, May 12, 2001
- 7.5.16
InnoDB
Contact Information
- 7.6
BDB
or BerkeleyDB
Tables
Add your own comment.