`

ORA-22858问题详解

阅读更多

  近日工作中发现有一张表的字段类型建错了,本应是CLOB类型却建成了VARCHAR2(4000),修改时oracle却提示“ORA-22858 invalid alteration of datatype”错误。
经查看相关资料才了解,是oracle不允某些类型的字段修改。具体就是不可以将字段类型修改为:object、REF、nested table、VARRAY、 CLOB、BLOB。
解决方案也很简单就是像学数据结构时经常用到的两变量(a,b)交换值的方法,c = a, a = b, b = c。当然我们这里可以简单处理,具体方法如下:
1、将字段a改名为a_copy
2、新建一个字段a,用正确的类型
3、将_a字段中的数据经一定转换(一般要做转换的,因为类型变了)后插入了a字段中
4、删除_a字段
如果无需保留数据只要1、2、3步就可以了。
如果表中或该字段中还没有数据,那就更简单了,把那个字段删除再以正确的数据类型新建一个即可。


正面是本错误的官方解释:

ORA-22858 invalid alteration of datatype

Cause: An attempt was made to modify the column type to object, REF, nested table, VARRAY or LOB type.

Action: Create a new column of the desired type and copy the current column data to the new type using the appropriate type constructor.

原文地址:ttp://12447680.blog.163.com/blog/static/17614089200811323126233/

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics