MySQL Getting Started Guide

Source: Internet
Author: User
Tags create index mysql mysql manual

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));

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.