Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to rename table with qualified target table name #10234

Closed
nielsmeijer opened this issue May 29, 2020 · 3 comments
Closed

Unable to rename table with qualified target table name #10234

nielsmeijer opened this issue May 29, 2020 · 3 comments

Comments

@nielsmeijer
Copy link

When renaming a table using jOOQ on Oracle dialect using qualified table names, an oracle exception is raised: ORA-14047: ALTER TABLE|INDEX RENAME may not be combined with other operations.

Code sample:

DSL.using(SQLDialect.ORACLE12C)
.alterTable(name("schema_name", "old_table_name"))
renameTo(name("schema_name", "new_table_name"))
.execute();

jOOQ translates this code the following SQL query

alter table "MY_SCHEMA"."MY_TABLE"
  rename to "MY_SCHEMA"."NEW_NAME"

The query fails on the database with ORA error ORA-14047

When you omit the schema name, the query executes without any issue:

DSL.using(SQLDialect.ORACLE12C)
.alterTable(name("schema_name", "old_table_name"))
renameTo(name("new_table_name"))
.execute();
alter table "MY_SCHEMA"."MY_TABLE"
  rename to "NEW_NAME"

Versions:

  • jOOQ: tested on 3.13.2 (pro)
  • Database: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0
  • JDBC Driver: oracle ojdbc7
@lukaseder
Copy link
Member

Thank you very much for your report.

I think there had been similar cases in the past where qualified renames didn't work for other object types. We should add integration tests for all of these rename operations to make sure qualification works if the source and target schema are the same, which should always work irrespective of the dialect.

@lukaseder
Copy link
Member

Looking into this now. This isn't Oracle specific. Numerous dialects are affected, among others:

  • Db2
  • Derby
  • Informix
  • Oracle
  • SQL Server

We're already unqualifying the target table name in:

  • BigQuery
  • CockroachDB
  • PostgreSQL
  • Redshift
  • YugabyteDB

I'm not sure why this hasn't been done yet for all affected dialects.

@lukaseder lukaseder changed the title Unable to rename table with qualified table name on Oracle dialect Unable to rename table with qualified target table name May 12, 2023
lukaseder added a commit that referenced this issue May 12, 2023
lukaseder added a commit that referenced this issue May 12, 2023
lukaseder added a commit that referenced this issue May 12, 2023
lukaseder added a commit that referenced this issue May 12, 2023
@lukaseder
Copy link
Member

Fixed in jOOQ 3.19.0, 3.18.5 (#15066), 3.17.14 (#15067), and 3.16.20 (#15068)

3.13 DDL interpretation automation moved this from To do to Done May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants