【问题标题】:How to import data into a varray using sqlldr如何使用 sqlldr 将数据导入可变数组
【发布时间】:2017-12-04 13:58:39
【问题描述】:

我正在尝试使用 sqlldr 将数据导入 Oracle 数据库。

我正在使用此文档,但未成功:sqlldrsqlldr2

描述我在做什么:

创建可变数组类型和表:

CREATE OR REPLACE TYPE fv_integer_varray_12 AS VARRAY(12) OF INTEGER NOT NULL;

CREATE OR REPLACE TYPE VC_Array_MInteger_12 AS Object (
  fv_array fv_integer_varray_12,
  MEMBER FUNCTION   typeDimension   RETURN NUMBER ,
  MEMBER FUNCTION typeName RETURN VARCHAR2);
/  

CREATE TABLE fv_varray_12 (
id NUMBER, 
fv fv_integer_varray_12,
PRIMARY KEY (id)
);

创建控制文件:

options (errors=9999999, rows=5)
load data
 characterset WE8MSWIN1252
 infile '<path>'
 badfile '<path>'
 discardfile '<path>'
 into table fv_varray_12
 fields terminated by " "
( id, fv VARRAY COUNT(12) (fv))

要加载的数据是:

8 18 29 38 9 16 15 14 16 18 16 13 15 
9 22 31 32 8 13 18 10 15 18 16 13 13 

当我尝试通过命令加载它时:

sqlldr user/pass control=imp_fv_12dim.ctl

我得到错误:

SQL*Loader-403:表 FV_VARRAY_12 中不存在引用的列。

但这不是真的,因为 id 和 fv 列都在那里。

我的控制文件一定有问题。我该如何解决?

【问题讨论】:

    标签: oracle loader sql-loader varray


    【解决方案1】:

    您只是缺少关键字CONSTANT

    fv VARRAY COUNT(CONSTANT 12) (fv)
    

    文档中的示例中缺少这一点(但他们的数据看起来也很奇怪);但它显示为必需的in the count_spec syntax diagram,它在加载 VARRAY 时从the 12c documentaion 链接到 - 但也可在早期版本的文档中使用..

    使用您的示例数据以及对控制文件的修改:

    options (errors=9999999, rows=5)
    load data
    characterset WE8MSWIN1252
    infile 'imp_fv_12dim.dat'
    badfile 'imp_fv_12dim.bad'
    discardfile 'imp_fv_12dim.dis'
    into table fv_varray_12
    fields terminated by " "
    ( id,
      fv VARRAY COUNT(CONSTANT 12) (fv)
    )
    

    然后就可以了:

    > sqlldr user/pass control=imp_fv_12dim.ctl
    
    SQL*Loader: Release 11.2.0.4.0 - Production on Mon Dec 4 17:41:04 2017
    
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    
    Commit point reached - logical record count 2
    

    查询显示数据:

    column fv format a80
    select * from fv_varray_12;
    
            ID FV                                                                              
    ---------- --------------------------------------------------------------------------------
             8 FV_INTEGER_VARRAY_12(18, 29, 38, 9, 16, 15, 14, 16, 18, 16, 13, 15)             
             9 FV_INTEGER_VARRAY_12(22, 31, 32, 8, 13, 18, 10, 15, 18, 16, 13, 13)             
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-20
      • 1970-01-01
      • 1970-01-01
      • 2012-01-17
      • 1970-01-01
      • 1970-01-01
      • 2019-07-12
      相关资源
      最近更新 更多