3

私はOracle 10gを使用しましたが、このfile.ctlがあります

OPTIONS (SKIP=1)
LOAD DATA
INFILE '/home/gxs/segmentation/sqlloader/datos.csv'
APPEND INTO TABLE test
(id "s_test.nextval",
name char(10) TERMINATED BY ',' ,
tel char(20) TERMINATED BY ',' ,
apellido char(10) TERMINATED BY ',' )

私のcsvファイルes

name,tel,apellido
daniel,12345,buitrago
cesar,98765,san
alex,4556,ova

しかし、テーブルを見ると、名前には最初の文字がありません:

id   name   apellido   tel
1    aniel  buitrago   12345
2    esar   san        98765
3    lex    ova        4556

どうする?

4

1 に答える 1

5

As per the documentation, you need to use the EXPRESSION keyword to show that the value is coming purely from the specified expression and is not dependent on anything in the data file:

OPTIONS (SKIP=1)
LOAD DATA
INFILE '/home/gxs/segmentation/sqlloader/datos.csv'
APPEND INTO TABLE test
(id EXPRESSION "s_test.nextval",
name char(10) TERMINATED BY ',' ,
tel char(20) TERMINATED BY ',' ,
apellido char(10) TERMINATED BY ',' )

... which inserts:

        ID NAME       TEL        APELLIDO
---------- ---------- ---------- ----------
         1 daniel     12345      buitrago
         2 cesar      98765      san
         3 alex       4556       ova

At the moment it's assuming ID is a field in your data file, and since you haven't specified a data type it's defaulting to char with size 1, which is consuming the first character of your real first field.

于 2013-09-23T07:06:09.073 に答える