Oracle:将VARCHAR2列更改为CLOB [英] Oracle: Changing VARCHAR2 column to CLOB

查看:403
本文介绍了Oracle:将VARCHAR2列更改为CLOB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,我试图存储在varchar2(4000)列中的数据太大,因此我希望将该列更改为一个更适合于存储大量文本数据的列.具体来说,是一个序列化数组.

I have an encountered an issue where the data I was trying to store in my varchar2(4000) column was too big, so I wish to change the column to one more suitable for storing large amounts of textual data. Specifically, a serialized array.

  1. 首先,CLOB是否是我用于此目的的最佳数据类型?有更合适的数据类型吗?

  1. Firstly, is CLOB the best data type for me to use for this purpose? Is there a more appropriate data type?

其次,当我尝试使用常用的语法更改列时:

Secondly, when I try to alter the column using the usual snyntax:

ALTER TABLE table MODIFY column CLOB

我收到以下错误: ORA-22858:数据类型的无效更改

在不丢失任何数据的情况下更改此表的最直接方法是什么?

What's the most straightforward way to alter this table without losing any data?

推荐答案

考虑到不允许从varchar列移动到CLOB的操作,最直接的方法是创建一个新列,然后将数据从旧列移到新列:

The most straightforward way, given that the operation of moving from a varchar column to a CLOB is disallowed, would be to create a new column and move the data from the old column to the new column:

ALTER TABLE some_table ADD (foo CLOB);
UPDATE some_table SET foo = old_column;
ALTER TABLE some_table DROP COLUMN old_column;
ALTER TABLE some_table RENAME COLUMN foo TO old_column;

这篇关于Oracle:将VARCHAR2列更改为CLOB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆