40

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:

<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

user2187935
  • 751
  • 2
  • 8
  • 19

3 Answers3

99

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.

JavaDevSweden
  • 2,154
  • 2
  • 18
  • 29
3

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.

<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>
Code Buster
  • 195
  • 1
  • 11
-10

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

Barry Kaye
  • 7,682
  • 6
  • 42
  • 64
Mohammad Nadeem
  • 9,134
  • 14
  • 56
  • 82
  • 13
    The above will not work, because you are not setting the value field. So it will not give appropriate result. The final one is indicated in below post. – Code Buster Apr 13 '17 at 11:13