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

被折叠的 条评论
为什么被折叠?



