Short List of MySQL Commands
Short List of MySQL Commands
Items that can be repeated as often as desired are indicated by an ellipsis ...
User names are NOT quoted in GRANT or REVOKE statements, but they are
quoted in other statements.
General Commands
USE database_name
Change to this database. You need to change to some database when you first
connect to MySQL.
SHOW DATABASES
Lists all MySQL databases on the system.
DESCRIBE table_name
SET PASSWORD=PASSWORD('new_password')
Allows the user to set his/her own password.
Table Commands
CREATE TABLE table_name (create_clause1, create_clause2, ...)
Creates a table with columns as indicated in the create clauses.
create_clause
column name followed by column type, followed optionally by modifiers. For
example, "gene_id INT AUTO_INCREMENT PRIMARY KEY" (without the quotes)
creates a column of type integer with the modifiers described below.
create_clause modifiers
PRIMARY KEY : Items in this column have unique names, and the table is
indexed automatically based on this column. One column must be the
PRIMARY KEY, and only one column may be the PRIMARY KEY. This column
should also be NOT NULL.
NOT NULL : No NULL values are allowed in this column: a NULL generates
an error message as the data is inserted into the table.
DEFAULT value : If a NULL value is used in the data for this column, the
Data Commands
LOAD DATA LOCAL INFILE 'path to external file' INTO TABLE table_name
Loads data from the listed file into the table. The default assumption is that
fields in the file are separated by tabs, and each data record is separated from
the others by a newline. It also assumes that nothing is quoted: quote marks are
considered to be part of the data. Also, it assumes that the number of data fields
matches the number of table columns. Columns that are AUTO_INCREMENT
should have NULL as their value in the file.