MySQL Forums
Forum List  »  General

LOAD DATA INFILE & behaviour of AUTO_INCR regarding order
Posted by: stefan fuhrmann
Date: September 01, 2014 09:33AM

Hello,

I have a question regarding the order of the IDs in columns that are auto_increment when faced with a data import via LOAD DATA INFILE:

Will the IDs always be in ascending order fitting to the entries in my CSV file? I'm sorry if my question is hard to understand, since I'm having problems to describe it properly, so I'll give you an example:

CSV looks like this:
col1;col2
---------
a;x
y;b
z;c

When importing this file w/ LOAD DATA INFILE into a table with an auto_increment column, is it guaranteed that it will look like this? :

col1;col2;ai_ID
----------------
a;x;1
y;b;2
z;c;3


Since I have (a lot) of csv-files with hourly values, but no timestamp or similar, I need to put the values 1-24 for first hour, second hour etc. next to the values. If it was guaranteed, that the auto_increment works as I hope it does, I wouldn't have to manipulate the input files (or read every single line into my table) and could import them into a temporary table (create/drop for every input file) and then copy the data into the final data table.


I hope someone knows how exactly LOAD DATA INFILE and AUTO_INCREMENT work together :)


Thank you very much

Options: ReplyQuote


Subject
Written By
Posted
LOAD DATA INFILE & behaviour of AUTO_INCR regarding order
September 01, 2014 09:33AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.