Notes about mysql _ MySQL

Source: Internet
Author: User
Notes about mysql: bitsCN.com

1. if the Key is null, the column value can be repeated, indicating that the column has no index or a non-leading column with a non-unique composite index.
2. if the Key is PRI, this column is an integral part of the primary Key.
3. if the Key is UNI, this column is the first column (leading column) of a unique value index, and does not contain NULL values)
4. if the Key is MUL, the values of this column can be repeated. This column is a non-unique index leading column (the first column) or a unique index component, but it can contain NULL values.

If the definition of a column meets the above four conditions, for example, a column is both PRI and UNI
When "desc table name" is used, the displayed Key value displays PRI-> UNI-> MUL based on the priority.
Then, PRI is displayed.

A unique index column can be displayed as PRI, and the column cannot contain null values. at the same time, the table does not have a primary key.

A unique index column can be displayed as MUL. if multiple columns constitute a unique compound index
Although the multi-column combination of indexes is unique, for example, ID + NAME is unique, no single column can still have duplicate values.
As long as ID + NAME is unique

1. add a new column to the table
Syntax alter table name add column name text not null text indicates data type not null indicates the field is not empty
2. delete the entire column of reserved column names
Syntax update table name set column name to be cleared = null
Update table name set name of the column to be cleared =''
3. delete columns
Alter table name drop column name
4. rename a column
Alter table name change original column name new column name original column type;
5. change the class type
Alter table name change column name new type;
6. rename a table
Alter table original table name rename New table name;
7. add a column attribute as the primary key
Alter table name add primary key (column name );
8. delete the primary key
Alter table name drop primary key;
9. Auto-increment deletion
Alter table name change id int (number );

BitsCN.com

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.