支持alter table move 的数据类型 :raw blob clob

本文通过实验详细阐述了在数据库迁移过程中,raw和blob类型支持move操作,而long和longraw类型无法直接进行move操作的原因。通过创建表并插入不同类型的数据,然后尝试在不同表空间间移动表,实验证明了raw和blob类型的灵活性,同时也揭示了long和longraw类型的局限性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

结论:
支持alter table move 的数据类型 :raw blob clob 
不支持的数据类型 :long 和 long raw

实践是检验真理的最佳方法!

测试过程

1.测试raw和blob类型

SQL> create table t_move (id raw(16),btype blob) tablespace users;
Table created.

SQL> insert into t_move values ('411FC41933DECA4BA6298877EB4446CF',null);
1 row created.

同一个表空间内move操作:

SQL> alter table t_move move tablespace users;

Table altered.

SQL> select * from t_move;
ID
--------------------------------
BTYPE
--------------------------------------------------------------------------------
411FC41933DECA4BA6298877EB4446CF

1 row selected.

跨表空间的move操作:

SQL> alter table t_move move tablespace test;
Table altered.

SQL> select * from t_move;
ID
--------------------------------
BTYPE
--------------------------------------------------------------------------------
411FC41933DECA4BA6298877EB4446CF

1 row selected.

成功。
实验证明 raw和blob类型支持move操作。

2.测试long和long raw类型

SQL> alter table t_move add (high_value long);
Table altered.

SQL> insert into t_move values ('23E23F4E23C97D4AAAB781A9F8F085F2',null,'long')
  2  /

1 row created.

SQL> alter table t_move move tablespace test; 
alter table t_move move tablespace test
*
ERROR at line 1:
ORA-00997: illegal use of LONG datatype

SQL> alter table t_move move tablespace users;
alter table t_move move tablespace users
*
ERROR at line 1:
ORA-00997: illegal use of LONG datatype

失败
实验证明 long类型不能直接move。


SQL> alter table t_move add (high long raw);
alter table t_move add (high long raw)
                        *
ERROR at line 1:
ORA-01754: a table may contain only one column of type LONG

这里注意:long raw实验也是long类型的列,一张表内只能允许一个long类型的列。
所以,删除原long列再添加新long raw列。

SQL> alter table t_move drop column high_value;
Table altered.

SQL> alter table t_move add (high long raw);
Table altered.

SQL> desc t_move
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                                 RAW(16)
 BTYPE                                              BLOB
 HIGH                                               LONG RAW

SQL> alter table t_move move tablespace test;
alter table t_move move tablespace test
*
ERROR at line 1:
ORA-00997: illegal use of LONG datatype

失败
实验证明 long raw类型不能直接move。


SQL> alter table t_move drop column high;
Table altered.

SQL> alter table t_move add (tc clob);
Table altered.

SQL> desc t_move
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
  ID                                                RAW(16)
 BTYPE                                              BLOB
 TC                                                 CLOB

SQL> alter table t_move move tablespace users;

Table altered.

成功
实验证明 clob类型支持直接move。

SQL> drop table t_move;
Table dropped.

实验结束。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值