ORA-01031: insufficient privileges when bulk loading data from one schema to another via SQL*Loader

StackOverflow https://stackoverflow.com/questions/21530569

  •  06-10-2022
  •  | 
  •  

Question

I am trying to INSERT data into another schema's table via SQL Loader. Here is the control file:

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
 )

Notice I'm inserting into table SCHEMA.TABLE_NAME. Since I'll be sqlldr'ing from the schema depotapp01, I'll run the following command on globalref01:

GRANT INSERT ON dw_stg_holiday_extract TO depotapp01;

Check and see if it works:

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

That confirms I have INSERT privs from depotapp01:

GLOBALREF01 DW_STG_HOLIDAY_EXTRACT  GLOBALREF01 INSERT  NO  NO

Now, when I try to execute the sqlldr command, I get ORA-01031: insufficient privileges:

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

So my question is, now that I know I have INSERT privileges, what other privileges do I need to grant in order for this to work?

Was it helpful?

Solution

I think you also need the SELECT privilege in most cases because SQL*Loader performs checks before inserting.

In particular, the default loading option is INSERT:

INSERT

This is SQL*Loader's default method. It requires the table to be empty before loading. SQL*Loader terminates with an error if the table contains rows.

In order to check that the table is empty, the account used by SQL*Loader needs the SELECT privilege. You might not need it if loading as APPEND instead. Conversely, if you use the REPLACE or TRUNCATE option, you'll need additional privileges.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top