基于带子字符串的条件更新列值

t1qtbnec  于 2021-08-09  发布在  Java
关注(0)|答案(2)|浏览(489)

我需要更改包含 autor 子字符串到 author .
示例:我的当前行是 role-autor 这需要成为 role-author 在利基巴斯有可能吗?

vd2z7a6w

vd2z7a6w1#

像这样:

  1. <update tableName="your_table_name">
  2. <column name="role-autor" type="varchar(64)" valueComputed="REPLACE(role-autor, 'autor', 'author')" />
  3. <where>role-autor LIKE '%autor%'</where>
  4. </update>

请做的stackoverflow博客的研究有一些例子,可以帮助你。。。
您需要将其放入changeset标记中:

  1. <changeSet author="wiki" id="1.0.0-1">
  2. <update tableName="your_table_name">
  3. <column name="role-autor" type="varchar(64)" valueComputed="REPLACE(role-autor, 'autor', 'author')" />
  4. <where>role-autor LIKE '%autor%'</where>
  5. </update>
  6. </changeset>

有关变更集标记的更多详细信息,请参阅以下内容:https://docs.liquibase.com/concepts/basic/changeset.html

展开查看全部
s5a0g9ez

s5a0g9ez2#

你只是想 replace() ?

  1. update t
  2. set col = replace(col, 'autor', 'author')
  3. where col like '%autor%';

相关问题