用SQL加载器加载.tsv

问题描述 投票:0回答:1

我试图加载一个长度可变且有空白的tsv文件,但我无法加载它。

我的TSV文件有。

code   name   information surname   
1234   Peter              Peter
1111   Carl   exampleexample example Jhon

我正在尝试用:

OPTIONS (SKIP=1)
LOAD DATA
    INFILE 'EXAMPLE.TSV'
    INTO TABLE PERSON
    FIELDS TERMINATED BY ','
    OPTIONALLY ENCLOSED BY '"'  
    (
     CODE,
     NAME,
     INFORMATION,
     SURNAME
     )
oracle oracle11g sql-loader
1个回答
0
投票

下面是一个例子。

SQL> desc person
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 CODE                                               NUMBER
 NAME                                               VARCHAR2(10)
 INFORMATION                                        VARCHAR2(30)
 SURNAME                                            VARCHAR2(10)

SQL>

控制文件;注意 fields terminated by x'09'. 为了简单起见,我在控制文件中加入了样本数据。

options (skip=1)
load data 
infile *
replace
into table person
fields terminated by x'09'
( 
code,
name,
information,
surname
)

begindata
code    name    information surname
1234    Peter       Peter
1111    Carl    example exa John

测试。

SQL> $sqlldr scott/tiger control=test18.ctl log=test18.log

SQL*Loader: Release 11.2.0.2.0 - Production on Sri Tra 29 20:26:06 2020

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Commit point reached - logical record count 2

SQL> select * From person;

      CODE NAME       INFORMATION                    SURNAME
---------- ---------- ------------------------------ ----------
      1234 Peter                                     Peter
      1111 Carl       example exa                    John
© www.soinside.com 2019 - 2024. All rights reserved.