ORA-01031:通过SQL * Loader将数据从一个模式批量加载到另一个模式时,权限不足

时间:2014-02-03 14:59:42

标签: sql oracle sql-loader

我试图通过SQL Loader将数据插入到另一个模式的表中。这是控制文件:

LOAD DATA
 INFILE *
 INTO TABLE globalref01.dw_stg_holiday_extract
 FIELDS TERMINATED BY "|"
 TRAILING NULLCOLS
 (  ric_trd_exch,
    cntry_cde,
    holiday_date "TO_DATE (:holiday_date, 'YYYYMMDD')",
    holiday_desc,
    trd,
    stl
 )

注意我正在插入表SCHEMA.TABLE_NAME。由于我将从模式depotapp01进行sqlldr,因此我将在globalref01上运行以下命令:

GRANT INSERT ON dw_stg_holiday_extract TO depotapp01;

检查并查看它是否有效:

SELECT * FROM user_tab_privs_recd WHERE table_name = 'DW_STG_HOLIDAY_EXTRACT' AND owner = 'GLOBALREF01';

这证实我有来自depotapp01的INSERT权限:

GLOBALREF01 DW_STG_HOLIDAY_EXTRACT  GLOBALREF01 INSERT  NO  NO

现在,当我尝试执行sqlldr命令时,我得到了ORA-01031:权限不足:

SQL*Loader: Release 10.2.0.4.0 - Production on Mon Feb 3 09:41:43 2014

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Control File:   /db/platform/eq/sparc_SunOS_5.6/depot/2.0/DWRef/cfg/uat/2.1/base_config/holiday_calendar.ctl
Data File:      /export/data/depotdw/DWRef/data/oats/holiday_calendar.dat
  Bad File:     /export/data/depotdw/DWRef/data/oats/holiday_calendar.err
  Discard File: /export/data/depotdw/DWRef/data/oats/holiday_calendar.dsc
 (Allow all discards)

Number to load: ALL
Number to skip: 0
Errors allowed: 200000
Bind array:     64 rows, maximum of 1000000 bytes
Continuation:    none specified
Path used:      Conventional

Table GLOBALREF01.DW_STG_HOLIDAY_EXTRACT, loaded from every logical record.
Insert option in effect for this table: INSERT
TRAILING NULLCOLS option in effect

   Column Name                  Position   Len  Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
RIC_TRD_EXCH                        FIRST     *   |       CHARACTER
CNTRY_CDE                            NEXT     *   |       CHARACTER
HOLIDAY_DATE                         NEXT     *   |       CHARACTER
    SQL string for column : "TO_DATE (:holiday_date, 'YYYYMMDD')"
HOLIDAY_DESC                         NEXT     *   |       CHARACTER
TRD                                  NEXT     *   |       CHARACTER
STL                                  NEXT     *   |       CHARACTER

SQL*Loader-929: Error parsing insert statement for table GLOBALREF01.DW_STG_HOLIDAY_EXTRACT.
ORA-01031: insufficient privileges

所以我的问题是,既然我知道我有INSERT权限,我需要授予哪些其他权限才能使其正常工作?

1 个答案:

答案 0 :(得分:3)

我认为在大多数情况下你也需要SELECT权限,因为SQL * Loader在插入之前会执行检查。

特别是default loading option is INSERT

  

INSERT

     

这是SQL * Loader的默认方法。 需要表格   加载前为空。如果是,则SQL * Loader将终止并显示错误   表包含行。

为了检查表是否为空,SQL * Loader使用的帐户需要SELECT权限。如果加载为APPEND,则可能不需要它。相反,如果您使用REPLACETRUNCATE选项,则需要其他权限。