Mysql Storage Engines and Data Types
Mysql Storage Engines and Data Types
1. The purpose, advantages, disadvantages, and relevant configuration parameters of MySQL’s key storage
engines, namely ARCHIVE, BLACKHOLE, CSV, EXAMPLE, FEDERATED, InnoDB, MEMORY
(formerly HEAP), MERGE, and MyISAM.
2. The purpose and range of MySQL’s supported data types. To facilitate later reference, these data types
are broken into three categories: date and time, numeric, and textual.
3. MySQL’s table attributes, which serve to further modify the behavior of a data column.
4. The MySQL commands used to create, modify, navigate, review, and alter both databases and tables.
5. A relational database table is a data structure used to store and organize information.
6. SHOW is used for learning quite a bit about the server’s configuration, including user privileges,
supported table engines, executing processes, and more.
Creating a Table
A table is created using the CREATE TABLE statement.
CREATE TABLE employees (
id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
firstname VARCHAR(25) NOT NULL,
lastname VARCHAR(25) NOT NULL,
email VARCHAR(45) NOT NULL, phone
VARCHAR(10) NOT NULL, PRIMARY
KEY(id));
if you want to create the employees table only if it doesn’t already exist, do the
following:
Copying a Table
It’s a trivial task to create a new table based on an existing one. The following query
produces an exact copy of the employees table, naming it employees2:
CREATE TABLE employees2 SELECT * FROM employees;
An identical table, employees2, will be added to the database. Sometimes you need to create a
table based on just a few columns found in a preexisting table. You can do so by simply specifying
the columns within the CREATE SELECT statement:
CREATE TABLE employees3 SELECT firstname, lastname FROM employees;
InnoDB
InnoDB is a robust transactional storage engine released under the GNU General Public
License (GPL) that has been under active development for over a decade. InnoDB offers
users a powerful solution for working with very large data stores.
InnoDB tables are ideal for the following scenarios, among others:
• Update-intensive tables: The InnoDB storage engine is particularly
adept at handling multiple simultaneous update requests.
MyISAM
MyISAM used to be MySQL’s default storage engine. It resolved a number of deficiencies
suffered by its predecessor (ISAM). For starters, MyISAM tables are operating system
independent, meaning that you can easily port them from a Windows server to a Linux server.
In addition, MyISAM tables are typically capable of storing more data, but at a cost of less
storage space than their older counterpart. MyISAM tables also have the convenience of a
number of data integrity and compression tools at their disposal, all of which are bundled
with MySQL.
MyISAM tables cannot handle transactions and used to be preferred over InnoDB
when performance was an issue. Over time, the performance of InnoDB has increased
and is no longer an issue in most cases. The MyISAM storage engine was particularly
adept when applied to the following scenarios:
• Select-intensive tables: The MyISAM storage engine is quite fast at
sifting through large amounts of data, even in a high-traffic
environment.