如何在mariadb上创建函数索引?

如何在mariadb上创建函数索引?,mariadb,Mariadb,我正在尝试在mariadb 5.5上创建函数索引,如下所示 MariaDB [testdb]> create table foo(c1 datetime); Query OK, 0 rows affected (0.43 sec) MariaDB [testdb]> alter table foo add c2 varchar(10) AS (date_format(c1, '%Y-%m-%d')); Query OK, 0 rows affected (0.22 sec)

我正在尝试在
mariadb 5.5
上创建函数索引,如下所示

MariaDB [testdb]> create table foo(c1 datetime);
Query OK, 0 rows affected (0.43 sec)

MariaDB [testdb]> alter table foo add c2 varchar(10) AS (date_format(c1, '%Y-%m-%d')); 
Query OK, 0 rows affected (0.22 sec)               
Records: 0  Duplicates: 0  Warnings: 0

MariaDB [testdb]> desc foo;
+-------+-------------+------+-----+---------+---------+
| Field | Type        | Null | Key | Default | Extra   |
+-------+-------------+------+-----+---------+---------+
| c1    | datetime    | YES  |     | NULL    |         |
| c2    | varchar(10) | YES  |     | NULL    | VIRTUAL |
+-------+-------------+------+-----+---------+---------+
2 rows in set (0.03 sec)

MariaDB [testdb]> create index idx_foo on foo(c1, c2);
ERROR 1904 (HY000): Key/Index cannot be defined on a non-stored computed column
MariaDB [testdb]> 
是否有任何方法可以使用虚拟列创建基于组合列的索引

如有任何建议,将不胜感激

提前感谢。

请参阅文档:

10.2.2之前

在MariaDB 10.2.2及之前的版本中,以下声明适用于 生成列的索引:

  • 不支持在虚拟生成的列上定义索引


我用
PERSISTENT
创建了一个列,它工作正常。谢谢