alter VARCHAR column to TEXT under Oracle

60 views
Skip to first unread message

Ofir Herzas

unread,
Nov 8, 2015, 5:42:15 AM11/8/15
to sqlalchemy-alembic
Changing a VARCHAR column to CLOB (TEXT) raises the following exception under Oracle:

sqlalchemy.exc.DatabaseError: (cx_Oracle.DatabaseError) ORA-22858: invalid alteration of datatype
 
[SQL: 'ALTER TABLE tab MODIFY col CLOB']


While this is an Oracle fault, it would be nice if the abstraction layer took care of it.

The proposed solution that I found was to add a new clob column, copy the data, remove the old column and rename

Mike Bayer

unread,
Nov 8, 2015, 1:25:25 PM11/8/15
to sqlalchem...@googlegroups.com


On 11/08/2015 05:42 AM, Ofir Herzas wrote:
> Changing a VARCHAR column to CLOB (TEXT) raises the following exception
> under Oracle:
>
> |
> sqlalchemy.exc.DatabaseError:(cx_Oracle.DatabaseError)ORA-22858:invalid
> alteration of datatype
> [SQL:'ALTER TABLE tab MODIFY col CLOB']
>
> |
>
> While this is an Oracle fault, it would be nice if the abstraction layer
> took care of it.
>
> The proposed solution that I found was to add a new clob column, copy
> the data, remove the old column and rename

Alembic offers a rough version of this feature in the form of "batch
migrations", but that involves a whole table copy.

Recipes like adding new columns and copying data can be achieved using
custom directives, see
http://alembic.readthedocs.org/en/latest/cookbook.html#replaceable-objects
for an example of how to make new directives. I will gladly accept
documentation illustrating a recipe for this behavior.



>
> --
> You received this message because you are subscribed to the Google
> Groups "sqlalchemy-alembic" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sqlalchemy-alem...@googlegroups.com
> <mailto:sqlalchemy-alem...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Ofir Herzas

unread,
Nov 9, 2015, 2:25:47 AM11/9/15
to sqlalchem...@googlegroups.com
Thanks Mike,
I was hoping for a under-the-hood solution rather than a recipe since it's a must for using Oracle.
Nevertheless, if I get around it, I will provide the recipe (better to have something...)

In the meanwhile, I opted to stay with VARCHAR ...

Thanks again,
Ofir
You received this message because you are subscribed to a topic in the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy-alembic/rDqCsRIDfh4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sqlalchemy-alem...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages