This article is a mirror article of machine translation, please click here to jump to the original article.

View: 13178|Reply: 0

[Source] MySQL View and Create Index commands

[Copy link]
Posted on 3/1/2019 10:51:26 AM | | | |
Use the ALTER command to add and remove indexes

There are four ways to add an index to a data table:

ALTER TABLE tbl_name ADDPRIMARYKEY (column_list): This statement adds a primary key, which meansThe index value must be unique and cannot be NULL
ALTER TABLE tbl_name ADDUNIQUEindex_name (column_list): This statement creates an indexmust be unique (in addition to NULL, which can occur multiple times)
ALTER TABLE tbl_name ADDINDEXindex_name (column_list): AddNormal index, the index value can appear multiple times.
ALTER TABLE tbl_name ADDFULLTEXTindex_name (column_list): This statement specifies that the index is FULLTEXT for Full-text index


When creating an index, it is recommended to create it directly with the MySQL command line, not with MySQL Workbench to create it.

View the index




· Table

The name of the table.

· Non_unique

If the index cannot include duplicate words, it is 0. If you can, then 1.

· Key_name

The name of the index.

· Seq_in_index

Column sequence number in the index, starting from 1.

· Column_name

Column Name.

· Collation

How are columns stored in the index? In MySQL, there is a value 'A' (ascending) or NULL (no classification).

· Cardinality

An estimate of the number of unique values in the index. It can be updated by running ANALYZE TABLE or myisamchk -a. Cardinals are counted based on statistics that are stored as integers, so the value does not have to be precise even for small tables. The larger the cardinality, the greater the chance that MySQL will use that index when federated is made.

· Sub_part

If the column is only partially indexed, it is the number of characters that are indexed. If the entire column is indexed, it is NULL.

· Packed

Indicates how keywords are compressed. If it is not compressed, it is NULL.

· Null

If the column contains NULL, it contains YES. If not, the column contains NO.

· Index_type

Used indexing methods (BTREE, FULLTEXT, HASH, RTREE).

· Comment





Previous:C# After deserialization data processing return json()
Next:What are the common testing methods for bricklayer VPS? A complete list of VPS test methods for bricklayers
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com