At 8:28 PM -0500 9/22/99, Martin Ramsch wrote:
>On Wed, 1999-09-22 12:34:50 +0300, Bogdan Paduraru wrote:
>> LOAD DATA LOCAL INFILE file_path/file_name INTO TABLE log, wich is ok.
>> The problem is next time the file will have the same lines plus 1 to
>> N new lines. What can I do to make mySQL to load from that file
>> only the new lines (that 1 to N), the ones nonexistent in my table
>> (previously loaded), without the lines loaded last time.
>
>You should define a PRIMARY KEY or an UNIQUE INDEX on this table.
>Then use
> LOAD DATA
> LOCAL INFILE 'file_path/file_name'
> IGNORE /* <- this is the main point */
> INTO TABLE log;
>
>With IGNORE duplicates are skipped. Alternatively you could use
>REPLACE and duplicates (with respect to the UNIQUE INDEX) replace
>exiting rows.
>
>See chapter "7.15 LOAD DATA INFILE syntax" of the MySQL manual.
Or, if you know which line you want to begin at, you could specify
IGNORE later on in the command to skip the first several lines.
LOAD DATA [LOW_PRIORITY] [LOCAL] INFILE 'file_name.txt' [REPLACE | IGNORE]
INTO TABLE tbl_name
[FIELDS
[TERMINATED BY '\t']
[OPTIONALLY] ENCLOSED BY '']
[ESCAPED BY '\\' ]]
[LINES TERMINATED BY '\n']
[IGNORE number LINES] <-------- this skips initial lines
[(col_name,...)]
--
Paul DuBois, paul@stripped