SQL 使用 liquibase 更新表中的一行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16627627/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 15:18:23  来源:igfitidea点击:

Update one row in the table, using liquibase

sqldatabaseliquibase

提问by user2187935

I was hoping if someone could verify if this is the correct syntax and correct way of populating the DB using liquibase? All, I want is to change value of a row in a table and I'm doing it like this:

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

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

All I want is to change one value in a row in some table. The above doesn't work, although application compiled and it didn't complain, but alas, the value wasn't changed.

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

Thank you

谢谢

采纳答案by Mohammad Nadeem

Yes it is possible. See the below syntax:

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

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

More info at Liquibase Update

Liquibase 更新中的更多信息

回答by JavaDevSweden

The above answers are overly complicated, for most cases this is enough:

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

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

important to use single quotes ' and not double quotes " in the WHERE clause.

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

回答by Code Buster

The above post can be modified to correct format in this way. Inserted value="1" which is the expected result in the question of this post.

上面的帖子可以通过这种方式修改为正确的格式。插入 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>