The sql statement to create an index is [CREATE INDEX indexName ON table_name (column_name)]. This is the most basic index and it has no restrictions.
#The operating environment of this article: windows10 system, mysql 5.7, thinkpad t480 computer.
The sql statement to create an index is as follows:
The following is the most basic syntax for creating an index, which has no restrictions.
CREATE INDEX indexName ON table_name (column_name)
If it is CHAR, VARCHAR type, length can be less than the actual length of the field; if it is BLOB and TEXT type, length must be specified.
Modify the table structure (add index)
ALTER table tableName ADD INDEX indexName(columnName)
Specify directly when creating the table
CREATE TABLE mytable( ID INT NOT NULL, username VARCHAR(16) NOT NULL, INDEX [indexName] (username(length)) );
Related recommendations: mysql video tutorial
The above is the detailed content of What is the sql statement to create an index?. For more information, please follow other related articles on the PHP Chinese website!