MySQL Getting Started guide, hope for everybody use!!
First, SQL crash
Here are some important SQL quick references, for SQL syntax and added features on standard SQL, please check the MySQL manual.
1. Create a table
A table is one of the most basic elements of a database, and can be independent of each other or associated with a table. The basic syntax for creating a table is as follows:
create table table_name
(column_name datatype {identity |null|not null},
…)
Where the parameters table_name and COLUMN_NAME must meet the requirements of the recognizer (identifier) in the user database, the parameter datatype is a standard SQL type or a type provided by the user database. Users use non-null clauses to enter data for each field.
CREATE table has other options, such as creating temporary tables and reading some fields from other tables using the SELECT clause to make a new table. Also, in the creation table is available primary key, key, index, and other identifiers to set some fields as the primary key or index.
To note in writing:
The complete list of fields is listed in a pair of parentheses.
Field names are separated by commas.
Add a space after the comma between the field names.
The last field name is not followed by a comma.
All SQL statements are semicolon ";" End.
Cases:
mysql> CREATE TABLE Test (Blob_col blob, index (Blob_col (10)));
2. Create an index
The index is used for queries against the database. The general database is built with multiple indexing schemes, each of which is proficient in a particular query class. Indexes can speed up the query process for a database. The basic syntax for creating an index is as follows:
create index index_name
on table_name (col_name[(length)],... )
Cases:
Mysql> CREATE INDEX part_of_name on customer (name (10));