oracle 是否可以使用 liquibase 更新数据库中的现有行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16655504/
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-19 01:40:38  来源:igfitidea点击:

is it possible to update an existing row in DB, using liquibase?

oracledatabaseliquibase

提问by user2187935

Tried to find an answer to this question, but couldn't.

试图找到这个问题的答案,但找不到。

So, for example I have this table:

所以,例如我有这张表:

TABLE:

桌子:

col1 | col2
123       0
124       1

and I want to change col2 value to 1 and this is how I'm trying to do it:

我想将 col2 值更改为 1,这就是我尝试这样做的方式:

<changeSet author="myName" id="7799">
        <sql>
        UPDATE TABLENAME;
        SET COL1='1' WHERE col1='123';
        </sql>
</changeSet>

Alas, it doesn't work. So, I was wondering if it is even possible to do that with liquibase? Since, most tags in the documentation have to do with creating table, adding columns etc.

唉,它不起作用。所以,我想知道是否有可能用 liquibase 做到这一点?因为,文档中的大多数标签都与创建表、添加列等有关。

回答by Mohammad Nadeem

You can use the following liquibase syntax to update:

您可以使用以下 liquibase 语法进行更新:

<changeSet author="myname" id="7799">
    <update catalogName="dbname"
            schemaName="public"
            tableName="TABLENAME">
        <column name="COL1" value='1' type="varchar(50)"/>
        <where>col1='123'</where>
    </update>
</changeSet>

For the other options available please check Liquibase Update

对于其他可用选项,请检查Liquibase 更新