Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1504 connectés 

  FORUM HardWare.fr
  Programmation
  SQL/NoSQL

  Insertion partielle avec LOAD DATA INFILE (MySQL)

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Insertion partielle avec LOAD DATA INFILE (MySQL)

n°1574255
groscul
chausson aux pommes
Posté le 13-06-2007 à 11:29:23  profilanswer
 

Salut,
 
Je me sers de la fonction "LOAD DATA INFILE" pour effectuer une insertion d'un fichier texte dans ma base de données.
 
                        LOAD DATA INFILE 'chemin_du_fichier'  
                        INTO TABLE presta  
                        FIELDS  
                       TERMINATED BY ';'  
                        ESCAPED BY '\\'  
                        LINES STARTING BY ''  
                        TERMINATED BY '\n'  
                        (id_presta, numero, date, lib_presta, comm, lib_periode, total, fa)
 
Ce que j'aimerais, ce serait que si l'id_presta de la ligne du fichier existe déja dans la table presta, alors la ligne n'est pas insérée.  Quelqu'un aurait-il une solution ?


Message édité par groscul le 13-06-2007 à 11:30:39
mood
Publicité
Posté le 13-06-2007 à 11:29:23  profilanswer
 

n°1574264
flo850
moi je
Posté le 13-06-2007 à 11:34:00  profilanswer
 

Citation :

The REPLACE and IGNORE  keywords control handling of input rows that duplicate existing rows on unique key values:
 
    *
 
      If you specify REPLACE, input rows replace existing rows. In other words, rows that have the same value for a primary key or unique index as an existing row. See Section 13.2.6, “REPLACE Syntax”.
    *
 
      If you specify IGNORE, input rows that duplicate an existing row on a unique key value are skipped. If you do not specify either option, the behavior depends on whether the LOCAL keyword is specified. Without LOCAL, an error occurs when a duplicate key value is found, and the rest of the text file is ignored. With LOCAL, the default behavior is the same as if IGNORE is specified; this is because the server has no way to stop transmission of the file in the middle of the operation.


http://dev.mysql.com/doc/refman/5.0/en/load-data.html

n°1574368
groscul
chausson aux pommes
Posté le 13-06-2007 à 13:46:42  profilanswer
 

D'accord merci beaucoup.


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  SQL/NoSQL

  Insertion partielle avec LOAD DATA INFILE (MySQL)

 

Sujets relatifs
Génération de fichier xml à partir de php mysql. [Résolu][MySQL] Procédure stockée : parcourir les résultats d'un SELECT ?
Problème D'insertion dans SQL[Resolu] [php/mySQL JS?] Case a cocher evenementielle.
?? Requette sql pour connaitre le nombre d'entrée dans une table mysql[C#] Problème requête MySql
Auto execution de requette avec mysql[mysql] Requete possible ?
[MySQL 5] remettre une valeur par défaut avec UPDATE[RÉSOLU] requête MySQL select prochains évènements
Plus de sujets relatifs à : Insertion partielle avec LOAD DATA INFILE (MySQL)


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR