【问题标题】:Update one row in the table, using liquibase使用 liquibase 更新表中的一行
【发布时间】:2013-05-13 17:15:06
【问题描述】:

我希望是否有人可以验证这是否是使用 liquibase 填充数据库的正确语法和正确方法?所有,我想要的是改变表中一行的值,我这样做是这样的:

<changeSet author="name" id="1231">
<update tableName="SomeTable">
    <column name="Properties" value="1" />
    <where>PROPERTYNAME = 'someNameOfThePropery"</where>
</update>
<changeSet>

我想要的只是更改某个表中的一行中的一个值。以上不起作用,虽然应用程序已编译并且它没有抱怨,但是唉,值没有改变。

谢谢

【问题讨论】:

  • 在 where 元素的末尾有一个 " 而不是 '。

标签: sql database liquibase


【解决方案1】:

上面的答案过于复杂,对于大多数情况来说这就足够了:

<changeSet author="name" id="123">
    <update tableName="SomeTable">
        <column name="PropertyToSet" value="1" />
        <where>otherProperty = 'otherPropertyValue'</where>
    </update>
</changeSet>

在 WHERE 子句中使用单引号 ' 而不是双引号 " 很重要。

【讨论】:

    【解决方案2】:

    可以通过这种方式修改上述帖子以更正格式。插入的 value="1" 这是本文问题中的预期结果。

    <changeSet author="name" id="1231">
        <update catalogName="dbname"
                schemaName="public"
                tableName="SomeTable">
            <column name="Properties" **value="1"** type="varchar(255)"/>
            <where>PROPERTYNAME = 'someNameOfThePropery'</where>
        </update>
    </changeSet>
    

    【讨论】:

      【解决方案3】:

      是的,这是可能的。请参阅以下语法:

      <changeSet author="name" id="1231">
          <update catalogName="dbname"
                  schemaName="public"
                  tableName="SomeTable">
              <column name="Properties" type="varchar(255)"/>
              <where>PROPERTYNAME = 'someNameOfThePropery'</where>
          </update>
      </changeSet>
      

      更多信息Liquibase Update

      【讨论】:

      • 以上行不通,因为你没有设置值字段。所以它不会给出适当的结果。最后一个在下面的帖子中指出。
      猜你喜欢
      • 2013-01-08
      • 2017-04-10
      • 2017-09-29
      • 1970-01-01
      • 1970-01-01
      • 2019-06-27
      • 2023-03-24
      • 2013-10-07
      • 1970-01-01
      相关资源
      最近更新 更多