【发布时间】:2018-05-27 10:20:55
【问题描述】:
有没有办法在 hsqldb 中使用函数索引?
我尝试了这 4 个:
<column name="LOWER(name)"/>
<column name="LCASE(name)"/>
<column name="LOWER(name)" computed="true"/>
<column name="LCASE(name)" computed="true"/>
在我的 createIndex 变更集中:
<changeSet author="dgt" id="unique-postgres" dbms="hsqldb">
<createIndex indexName="lower_case_index" tableName="users" unique="true">
<column name="LOWER(name)" computed="true"/>
</createIndex>
在文档中,我注意到 hsqldb 得到:LOWER 和 LCASE 内置函数,但其中任何一个都不适合我。
每次我遇到错误时:
原因:liquibase.exception.DatabaseException:意外令牌:( 必需:) [失败的 SQL:创建唯一索引 PUBLIC.lower_case_index ON PUBLIC.users(LOWER(name))]
我知道一个解决方案,我可以将列类型从 VARCHAR 更改为 VARCHAR_IGNORECASE,但对我来说不是这种情况,因为我需要一个解决方案来同时处理 db:hsqldb 和 postgres。
我理想的解决方案应该是这样的:
<changeSet author="dgt" id="users-unique-index-postgres" dbms="hsqldb">
<createIndex indexName="name_index" tableName="users" unique="true">
<column name="LOWER(name)" computed="true"/>
</createIndex>
</changeSet>
<changeSet author="dgt" id="users-unique-index-hsqldb" dbms="postgresql">
<createIndex indexName="name_index" tableName="users" unique="true">
<column name="lower(name)" computed="true"/>
</createIndex>
</changeSet>
但它不起作用。
【问题讨论】:
标签: postgresql hsqldb liquibase