Hi,

As documented, for H2 the syntax is:

    ALTER TABLE ALTER COLUMN x RENAME TO y

I'm not sure if Oracle supports that as well. As for rename, only renaming
the columns is currently supported:

    ALTER TABLE tableName RENAME TO newName

Patches are welcome!

Regards,
Thomas


On Monday, April 20, 2015, Steve Nester <[email protected]> wrote:

> Hi
>
> I am using Oracle for production and H2 as an in-memory test database.
> I'm having trouble with Oracle compatibility for the "rename column"
> statement.
>
> Specifically, the Oracle statement is:
>
> alter table "SOME_TABLE" rename column "COLUMN_A" to "COLUMN_B" ;
>
> I'm using Spring and Liquibase and I believe I have specified "use Oracle
> compatibility mode" correctly, but this statement is rejected by H2 as
> follows:
>
> Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement
> "ALTER TABLE ""SOME_TABLE"" RENAME COLUMN[*] ""COLUMN_A"" TO ""COLUMN_B""
> "; expected "TO"; SQL statement:
> alter table "SOME_TABLE" rename column "COLUMN_A" to "COLUMN_B" [42001-174]
>     at org.h2.message.DbException.getJdbcSQLException(DbException.java:332)
>     at org.h2.message.DbException.getSyntaxError(DbException.java:197)
>     at org.h2.command.Parser.getSyntaxError(Parser.java:504)
>     at org.h2.command.Parser.read(Parser.java:2867)
>     at org.h2.command.Parser.parseAlterTable(Parser.java:4971)
>     at org.h2.command.Parser.parseAlter(Parser.java:4412)
>     at org.h2.command.Parser.parsePrepared(Parser.java:316)
>     at org.h2.command.Parser.parse(Parser.java:289)
>     at org.h2.command.Parser.parse(Parser.java:265)
>     at org.h2.command.Parser.prepareCommand(Parser.java:226)
>     at org.h2.engine.Session.prepareLocal(Session.java:437)
>     at org.h2.engine.Session.prepareCommand(Session.java:380)
>     at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1138)
>     at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:168)
>     at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:156)
>     at
> liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:294)
>
> Is there H2 compatibility for a rename column statement?
>
> Thanks for any suggestions!
> Steve
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <javascript:_e(%7B%7D,'cvml','h2-database%[email protected]');>
> .
> To post to this group, send email to [email protected]
> <javascript:_e(%7B%7D,'cvml','[email protected]');>.
> Visit this group at http://groups.google.com/group/h2-database.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to