简体   繁体   中英

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. 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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