含有long字段表的复制
==========================
创建表并插入测试数据
SQL> create table an(id int,name long);
表已创建。
SQL> create table an_bak(id int,name long);
表已创建。
SQL> insert into an select 1,'an' from dual;
已创建 1 行。
SQL> commit;
提交完成。
---------------------------
将表中数据插入到备份表中
SQL> insert into an_bak select * from an;
insert into an_bak select * from an
*
第 1 行出现错误:
ORA-00997: illegal use of LONG datatype
报错原因:
---------------------------
使用copy命令复制表
SQL> copy from hnunicom/hnunicom@hl insert an_bak using select * from an;
数组提取/绑定大小为 15。(数组大小为 15)
将在完成时提交。(提交的副本为 0)
最大 long 大小为 80。(long 为 80)
1 行选自 hnunicom@hl。
1 行已插入 AN_BAK。
1 行已提交至 AN_BAK (位于 DEFAULT HOST 连接)。
---------------------------
验证数据
SQL> select * from an_bak;
ID NAME
---------- --------------------------------------------------------------------------------
1 an
=================================
将long字段转换成clob
oracle从8i开始就不推荐使用long数据类型
推荐使用lob来代替long
SQL> alter table an_bak modify(name clob);
表已更改。
SQL> create table an_bak_bak as select * from an_bak;
表已创建。
使用lob类型字段将不会产生类似long的问题
-----------------------------------
数据长度较小的情况下,clob与long是没有差别的
SQL> create table an_b (id int,name long);
表已创建。
SQL> insert into an_b select * from an_bak_bak;
已创建 1 行。
SQL> commit;
提交完成。
SQL> select * from an_b;
ID NAME
---------- ---------------------------------------------
1 an
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13177610/viewspace-673812/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/13177610/viewspace-673812/