CREATE INDEX Statement Functional key parts must adhere to the following rules. An error occurs if a key part definition contains disallowed constructs. This produces an error; the expressions are not enclosed within parentheses: Instead, write the key parts as nonfunctional key parts, without parentheses: For  CREATE TABLE ... LIKE , the destination table preserves functional key parts from the original table. Functional indexes are implemented as hidden virtual generated columns, which has these implications: For more information about applicable restrictions, see Section 13.1.20.8, “CREATE TABLE and Generated Columns” , and Section 13.1.9.2, “ALTER TABLE and Generated Columns” . UNIQUE  is supported for indexes that include functional key parts. However, primary keys cannot include functional key parts. A primary key requires the generated column to be stored, but functional key parts are implemented as virtual generated columns, not stored generated columns. SPATIAL  and  FULLTEXT  indexes cannot have functional key parts. If a table contains no primary key,  InnoDB  automatically promotes the first  UNIQUE NOT NULL  index to the primary key. This is not supported for  UNIQUE NOT NULL  indexes that have functional key parts. Nonfunctional indexes raise a warning if there are duplicate indexes. Indexes that contain functional key parts do not have this feature. To remove a column that is referenced by a functional key part, the index must be removed first. Otherwise, an error occurs. 2516 •The virtual generated column itself requires no storage. The index itself takes up storage space as any other index. •Subqueries, parameters, variables, stored functions, and loadable functions are not permitted. •Only functions permitted for generated columns are permitted for functional key parts. •Functional key parts inherit all restrictions that apply to generated columns. Examples: •Each functional key part counts against the limit on total number of table columns; see Section 8.4.7, “Limits on Table Column Count and Row Size” . •Functional key parts are not permitted in foreign key specifications. •A functional key part expression cannot refer to column prefixes. For a workaround, see the discussion of  SUBSTRING()  and  CAST()  later in this section. •A functional key part cannot consist solely of a column name. For example, this is not permitted: •In index definitions, enclose expressions within parentheses to distinguish them from columns or column prefixes. For example, this is permitted; the expressions are enclosed within parentheses: INDEX ((col1 + col2), (col3 - col4)) INDEX (col1 + col2, col3 - col4) INDEX ((col1), (col2)) INDEX (col1, col2)