关于long类型的操作,如果一个表中有Long类型,那么不能直接用ctas 。如:
SQL> desc test1;
名称 是否为空? 类型
----------------------------------------- -------- -----------
ID NUMBER
NAME LONG
SQL> create table test2 as select * from test1;
create table test2 as select * from test1
*
第 1 行出现错误:
ORA-00997: 非法使用 LONG 数据类型
可以采用的方法:
SQL> COPY FROM song/song@test to song/song@test create test2 using select * from test1;
数组提取/绑定大小为 15。(数组大小为 15)
将在完成时提交。(提交的副本为 0)
最大 long 大小为 80。(long 为 80)
表 TEST2 已创建。
1 行选自 song@test。
1 行已插入 TEST2。
1 行已提交至 TEST2 (位于 song@test)。
或者采用迂回的方法,即把long转换为lob:
SQL> create table test3 as select id,to_lob(name) name from test1;
表已创建。
SQL> desc test3
名称 是否为空? 类型
----------------------------------------- -------- ------------------------
ID NUMBER
NAME CLOB
如果对test1进行move也会报错:
SQL> alter table test1 move;
alter table test1 move
*
第 1 行出现错误:
ORA-00997: 非法使用 LONG 数据类型
只有先改为别的类型才能进行move.
SQL> alter table test1 modify name varchar2(20);
alter table test1 modify name varchar2(20)
*
第 1 行出现错误:
ORA-01439: 要更改数据类型, 则要修改的列必须为空
SQL> delete from test1;
已删除 1 行。
SQL> commit;
提交完成。
SQL> alter table test1 modify name varchar2(20);
表已更改。
SQL> alter table test1 move;
表已更改。
这种在生产环境还没有遇见过
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25099483/viewspace-714510/ ,如需转载,请注明出处,否则将追究法律责任。