下面我们来测试EnterpriseDB Migration 工具对于Oracle 大对象(LOB)的迁移情况;
首先在在Oracle实例Scott模式下创建具有LOB对象的表,如:
SQL> create table tlob (t1 int primary key,t2 clob,t3 blob);
Table created.
-- 并填充数据
SQL> begin
2 for i in 1..100 loop
3 insert into tlob values(i,rpad('A',9999,'Z'),hextoraw(i) );
4 end loop;
5 commit;
6 end;
7 /
PL/SQL procedure successfully completed.
打开EnterpriseDB Migration 工具界面,从树形图中找到需要迁移的表TLOB,选择进行在线迁移:
导出日志:
[Starting Migration]
源数据库连接信息...
连接 =jdbc:oracle:thin:@rh2.home:1521:G10R21
用户 =system
密码=******
目标数据库连接信息...
连接 =jdbc:edb://rh2.home:5444/subuser
用户 =maclean
密码=******
正在导入 Redwood 架构 SCOTT...
表列表: 'TLOB'
正在创建表...
正在创建表: TLOB
已创建 1 个表。
正在以 8 MB 批次大小加载表数据...
正在将大型对象加载到表: TLOB...
表数据加载摘要: 时间总计 (秒): 1.122 行数总计: 100 大小总计 (MB): 0.380859375
数据加载摘要: 时间总计 (秒): 1.122 行数总计: 100 大小总计 (MB): 0.39
正在创建约束: SYS_C005182
已成功导入架构 SCOTT。
迁移过程已成功完成。
迁移日志已保存到 C:\Users\windesk\.enterprisedb\migrationstudio\build60
******************** 迁移摘要 ********************
Tables: 1 来自 1
Constraints: 1 来自 1
全部对象: 2
成功计数: 2
失败计数: 0
*************************************************************
----------------FINISHED---------
下面我们到EnterpriseDB中去验证导入数据:
[enterprisedb@rh2 ~]$ psql
Password:
Welcome to psql 8.3.0.112, the EnterpriseDB interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with edb-psql commands
\g or terminate with semicolon to execute query
\q to quit
edb=# \c subuser
You are now connected to database "subuser".
subuser=# desc scott.tlob;
Table "scott.tlob"
Column | Type | Modifiers
--------+---------+-----------
t1 | numeric | not null
t2 | text |
t3 | bytea |
Indexes:
"sys_c005182" PRIMARY KEY, btree (t1)
subuser=# select count(*) from scott.tlob;
count
-------
100
(1 row)
可以看到装换过程中将clob类型转制为text,而blob类型则转制为bytea。postgre中text类型为可变无限长文本类型(variable unlimited length)。
正想去EnterpriseDB网站去查一下官方定义,却发现了以下留言:
We are in the process of updating our website. The site will not be available for the next few minutes. Sorry for the inconvenience.
The EnterpriseDB Web team. |
另外bytea类型为一种变长的二进制字串,postgre组织的文档对这2种类型的存储数据上限没有非常明确的叙述,就目前找到的文献可以肯定的是postgre V7中这两种类型大小限制为1G
那么如果Oracle 中Blob/Clob类型大小超过了1G,就可能导致迁移无法正常进行。