Ingnore primary key

 
CREATE TABLE file_names (
     id int(11) NOT NULL auto_increment,
     file_name text NOT NULL,
     PRIMARY KEY (id),
     UNIQUE KEY file_name (file_name(200))
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

Insert query

 
INSERT IGNORE INTO file_names (id , file_name) 
VALUES (NULL , 'a'), (NULL , 'a');
The table now contains one row with a filename of 'a'





Questions and answers:
Clink on Option to Answer




1. Insert and ignore primary key ...

  • a) INSERT IGNORE INTO mytable ...
  • b) INSERT INTO mytable ... IGNORE KEY


References: