0

I am currently facing the problem which the table order in the CSV file is different with the order when i required to load to. I wish to upload the data from csv file in different order with in the database. To best illustrate, i've shown example below

Table A:

Stud_ID | Name | Address

but i wanted to load in this order in Table B:

Name | Stud_ID | Address.

How should i write in control .CTL file under Fields Terminated By","(...)? Please advise. Thank you. :)

user1090842
  • 25
  • 1
  • 4

1 Answers1

0

The simplest way is to put columns in ctl file in the order used in data.

APPEND INTO TABLE TableB
FIELDS TERMINATED BY '|'(
    Name,
    Stud_ID,
    Address
)
user1645975
  • 101
  • 4
  • I mean if the arrangement of the columns are different, does it affects the load? – user1090842 Mar 18 '14 at 15:15
  • as long as columns are in the same order as defined in the ctl file they will be in correct columns, it's realy simple, like in insert: if you make insert into t (col_a, col_b) values ('a','b'); there will be value a in col_a and value b in col_b, but if you make insert into t (col_a, col_b) values ('b','a'); there will be a in col_b and b in col_a – user1645975 Mar 18 '14 at 15:51