1

Using liquibase 3.4.1 I want to rename my columns in Oracle to uppercase if they exist. I always get the following error no matter what I do:

Unexpected error running Liquibase: ORA-00957: duplicate column name
 [Failed SQL: ALTER TABLE "SYSTEM"."MYTABLE" RENAME COLUMN "id" TO "ID"]

My precondition looks like this:

    <changeSet author="sake" id="gfdgfd" dbms="oracle" objectQuotingStrategy="QUOTE_ALL_OBJECTS">
            <preConditions onFail="MARK_RAN" >          
                      <columnExists tableName="MYTABLE" columnName="id" />
            </preConditions>
            <renameColumn tableName="MYTABLE" oldColumnName="id" newColumnName="ID"/>
</changeSet>

I tried following: - removing objectQuotingStrategy - adding SQL check:

<sqlCheck expectedResult="1">
                SELECT COUNT(*) FROM USER_TAB_COLUMNS
                WHERE TABLE_NAME='MYTABLE'
                AND COLUMN_NAME='id'
            </sqlCheck>

Any idea why this happens? :/

insan-e
  • 3,883
  • 3
  • 18
  • 43
  • i know nothing of liquibase, but all oracle columns are stored in uppercase in the database system tables – davegreen100 Aug 04 '15 at 13:54
  • @davegreen100 That's not 100% true. By default column names (and tables, views and other objects names) are stored in upper case unless they are quoted with double quotes `"` at the time of creation. This restriction though mostly corresponds to objects created with standard DDL statements. Objects created programmatically by some tool may end up with mixed case if the tool quotes the identifiers by default. – Sentinel Aug 04 '15 at 16:54
  • @insan-e you can try a two stage rename where you first rename "id" to "tmp-ID" then to "ID". As for why this is happening, your tool probably uses a case insensitive search instead of case sensitive search. As such `"id"` is equal to `"ID"` or `"Id"` or `"iD"` – Sentinel Aug 04 '15 at 16:57

0 Answers0