【问题标题】:How we can update table A column by table B column value using liquibase yml script我们如何使用 liquibase yml 脚本逐个表 B 列值更新表 A 列
【发布时间】:2022-10-19 18:44:57
【问题描述】:

我想用表 B 的名称列值更新表 A 的名称列,其中表 B 的 id 存在于表 A 中。 我正在尝试使用 liquibase yml 脚本,但它不起作用。

databaseChangeLog:
- changeSet:  
    id:  update-name  
    author:  xyz  
    changes:  
    -  update:  
        columns:  
        -  column:  
            name:  name  
            value: A.name = B.name  
        tableName: A
        where:  A.a_id = B.id

【问题讨论】:

    标签: hibernate jpa liquibase liquibase-hibernate


    【解决方案1】:

    最后,我找到了一种为此编写 Liquibase 脚本的方法,我在这里发布它,可能对某人有帮助。 我刚刚调用了将数据从表 B.name 更新为 A.name 的本机查询。

    databaseChangeLog:
    - changeSet:  
        id: update-name
        author: xyz  
        changes:  
          - sql:
              update A set name = b.name from B b where id = b.id;
    

    【讨论】:

      猜你喜欢
      • 2012-11-23
      • 1970-01-01
      • 2014-05-10
      • 2021-03-10
      • 1970-01-01
      • 2021-02-18
      • 1970-01-01
      • 1970-01-01
      • 2018-10-08
      相关资源
      最近更新 更多