Selected MySQL Commands - dummies

Selected MySQL Commands

Part of HTML5 and CSS3 All-in-One For Dummies Cheat Sheet

MySQL is very helpful when building a database. The following table contains the minimal commands needed to create, populate, and query a database using MySQL.

Command Discussion
USE databaseName; Set the databaseName as the default database
DROP TABLE IF EXISTS tableName; Delete the entire table
CREATE TABLE tableName (

fieldName type modifiers,


Create a table called tableName with the fields defined by the
field lines.


INSERT INTO tableName VALUES ( …) ; Insert a new record into tableName. Values must be correct type
in correct order.
SELECT * FROM tableName WHERE condition ORDER BY field Select all fields from tableName which meet the condition. Sort
according to the given field.
UPDATE tableName SET field = value WHERE condition; Modify an existing record. Use condition to specify which
record is modified, and set given value(s) to specified
DELETE FROM tableName WHERE condition Delete any records from the tableName table that satisfy the
CREATE VIEW viewName AS query Create a virtual table containing the results of a complex
query (often an inner join or link table join)