将altibase内存库的表导出到oracle数据库,目前还没有比如dblink之类的可以直接使用。我们可以借助altibase的iloader工具来进行导出源表的表结构和数据,然后在oracle端借助sqlldr进行导入。iloader导出的数据格式是以'^'来间隔字段的。
从内存库导出表:
iloader -s 192.168.0.1 -u username -p passwd -port 20300 \
formout -f table_name.fmt -T table_name
iloader -s 192.168.0.1 -u username -p passwd -port 20300 \
out -f table_name.fmt -d table_name.dat -log table_name.log
table_name.fmt 内容:
table table_name
{
OWNER_ID integer;
OWNER_TYPE integer;
SYS_SVC_TYPE integer;
PRODUCT_ID integer;
ATTR_ID integer;
ATTR_VALUE bigint;
REGION_ID char (1);
ABS_ACTIVE_TIME date;
ABS_INACTIVE_TIME date;
MONTH integer;
VERSION_NO integer;
}
DATEFORM. YYYY/MM/DD HH:MI:SS
table_name.dat的内容
/home/altibase/tmp>more table_name.dat
1000000104017009^0^430418129^99020324^0^99010082^99020082^0^0^20090131164033^20500101000000
2009013000002049^0^430418129^99020324^0^99010082^99020082^0^0^20090201000000^20500101000000
2009013100002167^0^430418129^99030181^0^99000497^99420850^0^0^20090201000000^20500101000000
2009013100002213^0^430418129^99030194^0^99010086^99420850^0^0^20090131161120^20370101000000
2009013100002215^0^430418129^99020068^0^99010068^99020068^0^0^20090131161409^20090131164033
2009013100002222^0^431333326^99030205^0^99010082^99020082^0^0^20090201000000^20500101000000
2009013100002223^0^431333326^99030186^0^99010082^99020082^0^0^20090201000000^20500101000000
这里的fmt和dat并不是匹配的,我只是为了说明一下格式而已。
根据上面的表结构和dat文件,可以确定sqlldr用的控制文件 table_name.ctl:
LOAD DATA
INFILE 'table_name.dat'
INTO TABLE table_name
fields terminated BY '^'
trailing nullcols
(
OWNER_ID decimal external,
OWNER_TYPE decimal external,
SYS_SVC_TYPE decimal external,
PRODUCT_ID decimal external,
ATTR_ID decimal external,
ATTR_VALUE decimal external,
REGION_ID char ,
ABS_ACTIVE_TIME date "YYYY/MM/DD HH24:MI:SS",
ABS_INACTIVE_TIME date "YYYY/MM/DD HH24:MI:SS",
MONTH decimal external,
VERSION_NO decimal external
)
然后在oracle库建立表:
CREATE TABLE table_name
(
OWNER_ID NUMBER,
OWNER_TYPE NUMBER,
SYS_SVC_TYPE NUMBER,
PRODUCT_ID NUMBER,
ATTR_ID NUMBER,
ATTR_VALUE NUMBER,
REGION_ID CHAR(1),
ABS_ACTIVE_TIME DATE,
ABS_INACTIVE_TIME DATE,
MONTH NUMBER,
VERSION_NO NUMBER
)
;
导入到oracle库:
sqlldr username/passwd control=table_name.ctl log=table_name.log direct=true rows=10000
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10867315/viewspace-573380/,如需转载,请注明出处,否则将追究法律责任。