今天把数据导入另外一个库时,通过外部表的形式,具体怎么创建 见 :oracle 创建外部表实例演示https://blog.csdn.net/whandgdh/article/details/89381072
创建外部表数据代码如下:
create table grbillin_ext
(
genbillno VARCHAR2(36) not null ,
riskcode VARCHAR2(8) ,
comcode VARCHAR2(24) ,
feetype VARCHAR2(6) ,
billtype VARCHAR2(4),
ttyid VARCHAR2(18) ,
ttycode VARCHAR2(10),
uwyear NUMBER(4) ,
calsign NUMBER(1),
accym VARCHAR2(12) ,
duedate DATE ,
currency VARCHAR2(6) ,
sumfee NUMBER(16,2) ,
businessind VARCHAR2(2) ,
accchannel VARCHAR2(40) ,
plancode VARCHAR2(8) ,
reinscode VARCHAR2(24),
brokercode VARCHAR2(24),
paycode VARCHAR2(24),
taxind VARCHAR2(2)
)
organization external
(
type ORACLE_LOADER
default directory ext_data_dir
access parameters(
records delimited by newline
badfile ext_bad_dir :'grbillin%a_%p.bad'
logfile ext_log_dir :'grbillin%a_%p.log'
fields terminated by ','
missing field values are null
( genbillno ,
riskcode ,
comcode ,
feetype ,
billtype ,
ttyid ,
ttycode ,
uwyear ,
calsign ,
accym ,
duedate ,
currency ,
sumfee ,
businessind ,
accchannel ,
plancode ,
reinscode ,
brokercode ,
paycode ,
taxind )
)
location ('grbillin.dat')
)
parallel
reject limit unlimited;
但是 居然提示 ORA-30657: 操作在外部组织表上不受支持
把创建语句检查了很多变,一致没发现问题,但是后面发现报错的时候,光标会停留在 genbillno VARCHAR2(36) not null , 上,想到外部表不能进行DML操作,那是不是费控约束这些也不允许。
就把not null删除 ,创建成功。
但是查询外部表时不能获取到数据,找到创建外部表时的日志目录,并打开日志看到
从日志中看到 duedate 列由于是日期,转换时报错,
所以需要把建表语句中转换字段 duedate 改为 dudate DATE “YYYY-MM-DD”
missing field values are null
( genbillno ,
riskcode ,
comcode ,
feetype ,
billtype ,
ttyid ,
ttycode ,
uwyear ,
calsign ,
accym ,
duedate DATE "YYYY-MM-DD" ,
currency ,
sumfee ,
businessind ,
accchannel ,
plancode ,
reinscode ,
brokercode ,
paycode ,
taxind )
然后重建外部表,成功获取数据