SQLLDR generation of Oracle external tables

Source: Internet
Author: User
Tags create directory uncompress

Oracle's import tool, very fast, here to remember the use of external tables, usually external tables to remember too much syntax for example:

CREATE TABLE PROD_MASTER (  "EMPNO" NUMBER,  "ENAME" VARCHAR2(50),  "HIREDATE" DATE,  "DEPTNO" NUMBER)ORGANIZATION external (  TYPE oracle_loader  DEFAULT DIRECTORY ext_table  ACCESS PARAMETERS   (    RECORDS DELIMITED BY NEWLINE CHARACTERSET US7ASCII    preprocessor ext_table:‘uncompress.sh‘        BADFILE ‘EXT_TABLE‘:‘prod_master.dat.bad‘    LOGFILE ‘1.log_xt‘    READSIZE 1048576    FIELDS TERMINATED BY "," LDRTRIM     MISSING FIELD VALUES ARE NULL     REJECT ROWS WITH ALL NULL FIELDS     (      "EMPNO" CHAR(255)        TERMINATED BY ",",      "ENAME" CHAR(255)        TERMINATED BY ",",      "HIREDATE" CHAR(10)        TERMINATED BY ","        DATE_FORMAT DATE MASK ‘dd-mon-yyyy‘,      "DEPTNO" CHAR(255)        TERMINATED BY ","    )  )  location   (    ‘prod_master.dat.gz‘  ))REJECT LIMIT UNLIMITED

If you hit the whole hand, this workload is a bit large, you can consider the system itself, the steps are as follows:
1 Checking components:

SELECT * FROM V$OPTION WHERE PARAMETER = ‘Oracle Database Vault‘;select comp_id,comp_name, version, status from dba_registry;chopt disable dv

If you do not close

SQL> select * from prod_master;select * from prod_master*ERROR at line 1:ORA-29913: error in executing ODCIEXTTABLEOPEN calloutORA-29400: data cartridge errorKUP-04094: preprocessing cannot be performed if Database Vault is installed

2 Creating a Table

CREATE TABLE PROD_MASTER (  "EMPNO" NUMBER,  "ENAME" VARCHAR2(50),  "HIREDATE" DATE,  "DEPTNO" NUMBER)

3 Creating a control file
Cat Prod_master.ctl

load datainfile ‘/home/oracle/scripts/prod_master.dat.gz‘append into table prod_masterfields terminated by ","trailing nullcols(empno,ename,hiredate date(10) ‘dd-mon-yyyy‘,deptno)

4 Creating a storage directory

create directory ext as ‘/home/oracle/ext‘;grant read,write,execute on ext;

5 Creating statements that build external tables
sqlldr userid=hr/hr control=prod_master.ctl extern_table=gernerate_only log=create_table.sql
Modify this because compression is enabled:
PREPROCESSOR EXT:‘uncompress.sh‘ --Preprocessor before readsize

SQLLDR generation of Oracle external tables

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.