MySQL Commands
You’ve already seen the SHOW command, which lists tables, databases, and many other items. The commands you’ll use most often are listed in following table.
Command | Parameters | Meaning |
---|---|---|
ALTER | DATABASE, TABLE | Alter DATABASE or TABLE |
BACKUP | TABLE | Back up TABLE |
\C | Cancel Input | |
CREATE | DATABASE, TABLE | Create DATABASE or TABLE |
DELETE | (expression with TABLE & ROW) | Create ROW from TABLE |
DESCRIBE | TABLE | Describe the TABLE’S columns |
DROP | DATABASE,TABLE | Delete DATABASE or TABLE |
EXIT (CTRL-C) | Exit | |
GRANT | (user details) | Change user privileges |
HELP (\h, \?) | item | Display help on item |
INSERT | (expression with data) | Insert data |
LOCK | TABLE(s) | Lock TABLE(s) |
QUIT (\q) | Same as EXIT | |
RENAME | TABLE | Rename TABLE |
SHOW | (too many items to list) | List item’s details |
SOURCE | filename | Execute commands from filename |
STATUS (\s) | Display current status | |
TRUNCATE | TABLE | Empty TABLE |
UNLOCK | table(s) | Unlock TABLE(s) |
UPDATE | (expression with data) | Update an existing record |
USE | database | Use database |
We’ll cover most of these as we proceed, but first, you need to remember a couple of points about MySQL commands:
• SQL commands and keywords are case-insensitive. CREATE, create, and CrEaTe all mean the same thing. However, for the sake of clarity, the recommended style is to use uppercase.
• Table names are case-sensitive on Linux and Mac OS X, but case-insensitive on Windows. So for portability purposes, you should always choose a case and stick to it. The recommended style is to use lowercase for tables.