MySQL basic three-value type, index

Source: Internet
Author: User
Tags create index

My 1am,1pm

Numeric type

    1. Int (4)

    2. Float (5,2)

    3. Varchar (4)

Enum type

    1. Enum (' female ', ' male ')

    2. Set (' book ', ' Football ', ' A ' ....)

Constraint conditions

Null Default Extra

The default is allow default NULL

Not NULL default value

Key

Normal Index Index

Unique Indexes unique

PRIMARY Key PRIMARY Key

FOREIGN Key FOREIGN Key

Full-text index fulltext

View Index desc

Showindex from What is the difference between the two

CREATE index createindex xxx on table ();

UNIQUE INDEX

Delete index dropindex xxxx on table;

Build Table Specify index field

Primarykey alter TABLEXXX Modify Xcolumn ... primary key auto_increment

altertable XXX Add primary key ();

to remove the notice, first remove the auto_increment

altertable xxxx drop PRIMARY key;

Composite PRIMARY Key different when repeating, the table must be created

Foreign Key

1. the storage engine must be InnoDB

2. the field type must match the

3. the referenced field must be an indexed field

ForeignKey ( field ) References table ( field )

Onupdate Cascade on DELETE on cascade) Engine=innodb;


MySQL basic three-value type, index

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.