MySQL for the Internet of Things

(Steven Felgate) #1
Chapter 5 ■ MySQL priMer

What does this mean to you? It means you have the choice of different mechanisms for storing data. You
can specify the storage engine in the table CREATE statement shown in the following code sample. Notice the
last line in the command: this is how a storage engine is specified. Leaving off this clause results in MySQL
using the default storage engine. For the examples in this book, MySQL 5.5 uses the MyISAM storage engine
by default.


■Tip the default storage engine was changed from MyiSaM to innoDB in MySQL version 5.6.


CREATE DATABASE bvm;


CREATE TABLE bvm.books (
ISBN varchar(15) DEFAULT NULL,
Title varchar(125) DEFAULT NULL,
Authors varchar(100) DEFAULT NULL,
Quantity int(11) DEFAULT NULL,
Slot int(11) DEFAULT NULL,
Thumbnail varchar(100) DEFAULT NULL,
Description text
) ENGINE=MyISAM;


Great! Now, what storage engines exist on MySQL? You can discover which storage engines are
supported by issuing the SHOW STORAGE ENGINES command, as shown in Listing 5-2. As you see, there are a
lot to choose from. I cover a few that may be pertinent to planning IOT solutions.


■Note the following sections show how to work with MySQL on a typical Linux-like (actually Unix-like)


platform. i’ve found most iOt solutions will use forms of these platforms rather than Windows 10, but that may


change in the future. For now, i focus on exploring MySQL on these platforms rather than Windows. however,


many of the examples shown can be executed on Windows albeit with a different set of commands.


Listing 5-2. Available Storage Engines


mysql> SHOW STORAGE ENGINES \G
1. row
Engine: FEDERATED
Support: NO
Comment: Federated MySQL storage engine
Transactions: NULL
XA: NULL
Savepoints: NULL
2. row
Engine: MRG_MYISAM
Support: YES
Comment: Collection of identical MyISAM tables
Transactions: NO
XA: NO
Savepoints: NO

Free download pdf