List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 23 1999 1:28am
Subject:Re: LOAD DATA
View as plain text  
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
   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.

Martin Ramsch <m.ramsch@stripped> <URL: >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
LOAD DATABogdan Paduraru22 Sep
  • Re: LOAD DATAMartin Ramsch23 Sep
    • Re: LOAD DATAPaul DuBois23 Sep
  • Re: LOAD DATABogdan Paduraru24 Sep