MySQL for the Internet of Things

(Steven Felgate) #1

Chapter 5 ■ MySQL priMer


A great many commands are available in MySQL. Fortunately, you need master only a few of the more
common ones. The following are the commands you will use most often. The portions enclosed in <> indicate
user-supplied components of the command, and [...] indicates that additional options are needed.



  • CREATE DATABASE : Creates a database

  • USE : Sets the default database (not an SQL command)

  • CREATE TABLE [...]: Creates a table or structure to store data

  • INSERT INTO [...]: Adds data to a table

  • UPDATE [...]: Changes one or more values for a specific row

  • DELETE FROM [...]: Removes data from a table

  • SELECT [...]: Retrieves data (rows) from the table

  • SHOW [...]: Shows a list of the objects


Although this list is only a short introduction and nothing like a complete syntax guide, there is an
excellent online reference manual that explains every command (and much more) in great detail. You
should refer to the online reference manual whenever you have a question about anything in MySQL. You
can find it at http://dev.mysql.com/doc/.
One of the more interesting commands shown allows you to see a list of objects. For example, you can
see the databases with SHOW DATABASES, a list of tables (once you change to a database) with SHOW TABLES,
and even the permissions for users with SHOW GRANTS. I find myself using these commands quite frequently.


■Tip if you use the mysql client, you must terminate each command with a semicolon (;) or \G.


If you are thinking that there is a lot more to MySQL than a few simple commands, you are absolutely
correct. Despite its ease of use and fast startup time, MySQL is a full-fledged relational database
management system (RDBMS). There is much more to it than you’ve seen here. For more information about
MySQL, including all the advanced features, see the reference manual.


MYSQL—What DOeS It MeaN?


the name MySQL is a combination of a proper name and an acronym. SQL is Structured Query
Language. the My part isn’t the possessive form—it is a name. in this case, My is the name of the
founder’s daughter. as for pronunciation, MySQL experts pronounce it “My-S-Q-L” and not “my sequel.”

How to Get and Install MySQL


The MySQL server is available for a variety of platforms including most Linux and Unix platforms, Mac OS X,
and Windows. To download MySQL server, visit http://dev.mysql.com/downloads/ and click Community
and then MySQL Community Server. This is the GPLv2 license of MySQL.^4 The page will automatically detect
your operating system. If you want to download for another platform, you can select it from the drop-down list.


(^4) If you are a paid customer of Oracle and have a subscription or support agreement for MySQL, contact your sales
representative for details.

Free download pdf