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

oracle table rename requires the "TO" not schema-qualified #670

Closed
kipstakkr opened this issue Mar 19, 2020 · 4 comments
Closed

oracle table rename requires the "TO" not schema-qualified #670

kipstakkr opened this issue Mar 19, 2020 · 4 comments

Comments

@kipstakkr
Copy link

@kipstakkr kipstakkr commented Mar 19, 2020

I am trying to use op.rename_table with old_table_name, new_table_name and schema, but it is creating an incorrect SQL statement.

For example,
For the method call, op.rename_table('table_a', 'table_b', schema='tables')

Expected SQL statement to be executed:-

ALTER TABLE tables.table_a RENAME TO table_b

Actual SQL statement it is executing currently:-

ALTER TABLE tables.table_a RENAME TO tables.table_b
@zzzeek zzzeek added bug op directives oracle labels Mar 19, 2020
@zzzeek
Copy link
Member

@zzzeek zzzeek commented Mar 19, 2020

confirmed:


SQL> create table test_schema.foo(id integer);

Table created.

SQL> alter table test_schema.foo rename to bar;

Table altered.

SQL> alter table test_schema.bar rename to test_schema.bat;
alter table test_schema.bar rename to test_schema.bat
                                                 *
ERROR at line 1:
ORA-14047: ALTER TABLE|INDEX RENAME may not be combined with other operations


@zzzeek
Copy link
Member

@zzzeek zzzeek commented Mar 19, 2020

please use op.execute("ALTER TABLE tables.table_a RENAME TO table_b") for now, thanks.

@zzzeek zzzeek changed the title rename table is not working with Oracle DB oracle table rename requires the "TO" not schema-qualified Mar 19, 2020
@kipstakkr
Copy link
Author

@kipstakkr kipstakkr commented Mar 19, 2020

Cool. I'll go with your suggestion for now. Thanks. 👍

@sqla-tester
Copy link
Collaborator

@sqla-tester sqla-tester commented Mar 19, 2020

Mike Bayer has proposed a fix for this issue in the master branch:

Don't include schema in "to" portion of Oracle RENAME table https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/1803

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants