简体   繁体   English

如何为以下 Postgres 索引创建语句创建 Liquibase 变更集 - 在索引中连接 2 列

[英]How to create Liquibase changeset for below Postgres index creation statement - concat 2 columns in index

create index if not exists employee_index 
   on employee(emp_id, (emp_first_name|| ' ' ||emp_last_name));

I'm able to use the above statement in Postgres, I want to have it in my Liquibase changeset.我可以在 Postgres 中使用上面的语句,我想将它放在我的 Liquibase 变更集中。 I need to combine the first and last names as above in the index since it gives better performance.我需要在索引中组合上面的名字和姓氏,因为它提供了更好的性能。 I was told that I can't deviate from it.我被告知我不能偏离它。

You can create an expression based index by enclosing the expression in parentheses:您可以通过将表达式括在括号中来创建基于表达式的索引:

<createIndex tableName="employee" indexName="employee_index">
  <column name="emp_id"/>
  <column name="(emp_first_name||' '||emp_last_name)"/>
</createIndex>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM