Executer du SQL sans contrainte de clef etrengere

Executer du SQL sans contrainte de clef etrengere

Executer du SQL sans contrainte de clef etrengere

Imaginons que vous vouliez importer des milliers de données d'une table par exemple nommée "Livre" avec une clef vers Auteur mais que certains livres sont reliés à des auteurs qui n'existent pas encore ou plus. Il y a 1000 livres et juste deux ou trois livres qui empêchent l'insertion des 1000 livres et il vous est impossible de trouver quel livre pose problème avant l'insertion. Du coup l'erreur suivante vous empêche l'import:

Cannot add or update a child row: a foreign key constraint fails (`ideak`.`idk_ideak_livre`, CONSTRAINT `FK_AB6B82E6BCF5E72D` FOREIGN KEY (`auteur_id`) REFERENCES `idk_ideak_livre` (`id`) ON DELETE CASCADE) 

Il suffit d'utiliser la commande SQL suivante pour ignorer les contraintes de clef étrangère:

SET foreign_key_checks = 0;
INSERT INTO ....
SET foreign_key_checks = 1;

Vous pouvez après l'insertion chercher tous les livres qui n'ont pas d'auteur joint puis les supprimer ou leur ajouter un auteur wink

SELECT * FROM livre l LEFT JOIN auteur a ON l.auteur_id = a.id WHERE a.id IS NULL;

Avec cette commande vous savez quels sont les livres qui vous empêchaient l’insertion et vous pouvez en faire ce que vous voulez.

Fait par : Joris Saenger

Commentaires (41)

  • User Name308998

    z7lVck <a href="http://knezdfpideaa.com/">knezdfpideaa</a>, [url=http://mgmyxjqkpfqo.com/]mgmyxjqkpfqo[/url], [link=http://czpnbzjjjual.com/]czpnbzjjjual[/link], http://baqxuuqpchcm.com/

    04/12/2018 à 12:25 Répondre

    Ajouter un commentaire

    • User NameJamestog

      can i buy viagra online in australia <a href="http://viagrawithouatdoctor.com/#">real viagra without a doctor prescription</a> viagra generico in farmacia [url=http://viagrawithouatdoctor.com/#]real viagra without a doctor prescription[/url] viagra vs cialis price

      06/12/2018 à 12:57 Répondre

      Ajouter un commentaire

    • User NameBrettnig

      viagra de 100mg precio <a href="http://viagrawithouatdoctor.com/#">viagra without a doctor prescription</a> sildenafil generic usa [url=http://viagrawithouatdoctor.com/#]viagra without a doctor prescription walmart[/url] can get viagra

      06/12/2018 à 12:58 Répondre

      Ajouter un commentaire

    • User NameJamesinfom

      cheap safe viagra <a href="http://viagrawithouatdoctor.com/#">viagra without a doctor prescription walmart</a> buying cheap viagra online uk [url=http://viagrawithouatdoctor.com/#]viagra without a doctor prescription[/url] the other guys like a viagra pill with a face

      06/12/2018 à 12:58 Répondre

      Ajouter un commentaire

    • User Name1602

      What's the last date I can post this to to arrive in time for Christmas? <a href=" http://soprof.com.mx#pillar ">viagra</a> It took seven years and $27 million to create the first of seven mirrors for the Giant Magellan Telescope (GMT), but now UA astronomers and optical scientists are gearing up to crank them out much more quickly and cheaply.

      08/12/2018 à 01:06 Répondre

      Ajouter un commentaire

    • User Name138076

      Is there ? <a href=" http://ttstaller.com#pit ">clomid</a> Gross said in multiple interviews with the media that he did not see any indication of injury on the MRI, apparently verifying Team A-Rod’s claim that the Yankees were trying to keep the aging infielder off the field.

      08/12/2018 à 01:06 Répondre

      Ajouter un commentaire

    • User Name787221

      I've got a full-time job <a href=" http://ttstaller.com ">cialis</a> It seems unfair to blame Kraftwerk. They had brought their bodysuits and their computers, and the usual tools for working up a crowd (interacting with the audience, changing the set-list) aren't available to them.

      08/12/2018 à 01:06 Répondre

      Ajouter un commentaire

    • User Name9200

      I've been made redundant <a href=" https://weteachquran.com#root ">clomid</a> The JGB market shrugged off further evidence of slowinggrowth in China after activity in the country's manufacturingsector slowed to an 11-month low in July as new orders falteredand the job market weakened.

      08/12/2018 à 01:06 Répondre

      Ajouter un commentaire

    • User Name3474

      An envelope <a href=" http://vvasoftware.com ">clomid</a> "This is a very difficult situation, where we have a new vaccine against meningitis B but we lack important evidence," said Prof David Salisbury, the director of immunisation at the Department of Health.

      08/12/2018 à 01:06 Répondre

      Ajouter un commentaire

    • User Name9866

      Have you read any good books lately? <a href=" https://weteachquran.com ">diflucan</a> Sturgeon said: "Today's announcement signals the start of one of the most ambitious infrastructure projects in the whole of Europe. It will connect communities across rural and urban areas, providing a platform for future economic development and regeneration."

      08/12/2018 à 02:29 Répondre

      Ajouter un commentaire

    • User Name6433

      Children with disabilities <a href=" http://soprof.com.mx#crack ">cipro </a> &#8220;Poisoning is not really common as a means to kill elephants but, unfortunately, in recent years we have seen more instances. The Hwange massacre, however, is on a scale not previously witnessed,&#8221; says Tom Milliken, an expert on poaching and the illegal ivory trade at Traffic, a wildlife trade monitoring network.

      08/12/2018 à 02:29 Répondre

      Ajouter un commentaire

    • User Name211271

      I wanted to live abroad <a href=" http://vvasoftware.com ">diflucan</a> I am not the chattiest person and initially found it difficult to carry on random conversations until I realized that all I had to do was to bombard the other person with questions. I quickly built a reputation of being extremely pleasant to converse with, without ever really saying much.

      08/12/2018 à 02:29 Répondre

      Ajouter un commentaire

    • User Name5202

      I stay at home and look after the children <a href=" http://www.ccpirapuato.com#throw ">cipro </a> Doak, who lost his card at the end of his only previous season on the tour in 2009 and regained it by finishing 10th on the second-tier circuit last year, recorded five birdies, a bogey and an eagle at the long 12th to finish on 12 under.

      08/12/2018 à 02:29 Répondre

      Ajouter un commentaire

    • User Name756808

      Could I ask who's calling? <a href=" http://ttstaller.com ">ventolin</a> Some cookies on this site are essential, and the site will not work as expected without them. These cookies are set when you submit a form, login or interact with the site by doing something that goes beyond clicking on simple links. We also use some non-essential cookies to anonymously track visitors or enhance your experience of the site. If you're not happy with this, we won't set these cookies but some nice features of the site may be unavailable.

      08/12/2018 à 02:29 Répondre

      Ajouter un commentaire

    • User Name2735

      I was made redundant two months ago <a href=" https://weteachquran.com#pond ">cipro </a> "In the context of something that size, how much can we show in this stage in this case?" Kopel said. He said it&#39;s more appropriate to address issues surrounding background checks at trial.

      08/12/2018 à 03:53 Répondre

      Ajouter un commentaire

    • User Name5871

      Why did you come to ? <a href=" http://www.ccpirapuato.com#attempting ">clomid</a> The decision to "label the songs our fans have been singing and the chants our fans have been chanting for decades as racist overnight" was, it said, incomprehensible and could be in breach of freedom of expression legislation.

      08/12/2018 à 03:53 Répondre

      Ajouter un commentaire

    • User Name9810

      International directory enquiries <a href=" https://matrixglobal.net.id ">levitra</a> First came Afghanistan. Then Iraq, and then the authorization was used to justify even broader illegal wars. The text authorized force only against those who committed the 9/11 attacks and those who harbored them. Now Pentagon and administration officials routinely include organizations that didn't even exist in 2001. They reference "associated forces" of al-Qaida, as if that phrase was part of the authorization. It wasn't.

      08/12/2018 à 03:53 Répondre

      Ajouter un commentaire

    • User Name6764

      Will I get travelling expenses? <a href=" http://ttstaller.com#carlos ">clomid</a> Adams singled on a line drive for Holliday to score in the top of the ninth but it was too little too late for the Cardinals, who have twice lost the National League Championship Series after establishing 3-1 leads.

      08/12/2018 à 03:53 Répondre

      Ajouter un commentaire

    • User Name87815

      The manager <a href=" http://vvasoftware.com ">clomid</a> &ldquo;I&rsquo;ve been around a lot of places. People do awful things to each other. But it&rsquo;s worse in places where everybody is kept in the dark. It really is. Information is light. Information, in itself, about anything, is light. That&rsquo;s all you can say, really.&rdquo;

      08/12/2018 à 03:53 Répondre

      Ajouter un commentaire

    • User Name8480

      Children with disabilities https://matrixglobal.net.id diflucan The more enlightened approaches to rehabilitation available through the juvenile justice system include providing appropriate health and mental health intervention, educational and social services, as well as contact with attorneys and family members — all of which are better for young people and result in safer communities.

      08/12/2018 à 20:28 Répondre

      Ajouter un commentaire

    • User Name9333

      I'll put him on http://www.ccpirapuato.com kamagra Real-time U.S. stock quotes reflect trades reported through Nasdaq only; comprehensive U.S. stock quotes reflect trading in all markets and are delayed at least 15 minutes. All quote volume is comprehensive and reflects trading in all markets, delayed at least 15 minutes. International stock quotes are delayed as per exchange requirements.

      08/12/2018 à 20:28 Répondre

      Ajouter un commentaire

    • User Name804673

      Is this a temporary or permanent position? https://matrixglobal.net.id ventolin With the help of the European Broadcasting Union, which hosts the analogue station, they can reach around 65% of the country, as well as livestreaming on the internet. They have about 1.7 million regular viewers.

      08/12/2018 à 20:28 Répondre

      Ajouter un commentaire

    • User Name86925

      It's a bad line http://ttstaller.com cipro "When the macro economic environment comes back to being abit more positive and real wages start to grow we'll have veryprofitable businesses in that region," said chief financialofficer Laurie McIlwee, though he said Tesco's business ineastern Turkey, which lacks "critical scale", could see somerestructuring.

      08/12/2018 à 20:28 Répondre

      Ajouter un commentaire

    • User Name476733

      Can you put it on the scales, please? https://matrixglobal.net.id kamagra Dimon is now chairman emeritus of the subsidiary, accordingto a document released on Thursday, which is the public portionof the company's so-called "living will" filed with the FederalDeposit Insurance Corporation and Federal Reserve. Living willsof bank holding companies describe how the companies could betaken apart if they became financially distressed.

      08/12/2018 à 20:28 Répondre

      Ajouter un commentaire

    • User Name59135

      LeIn5C <a href="http://wirnywjksofk.com/">wirnywjksofk</a>, [url=http://rgvukmijyqqw.com/]rgvukmijyqqw[/url], [link=http://xymatuqfbfzc.com/]xymatuqfbfzc[/link], http://xllbdxljfgvz.com/

      10/12/2018 à 08:40 Répondre

      Ajouter un commentaire

    • User Name87053

      hm6XeX <a href="http://yiqftxycbbea.com/">yiqftxycbbea</a>, [url=http://izzpwehnqcei.com/]izzpwehnqcei[/url], [link=http://armfckqmceme.com/]armfckqmceme[/link], http://bygcrjlsmyjj.com/

      10/12/2018 à 15:17 Répondre

      Ajouter un commentaire

    • User Name29103

      OCVGX6 <a href="http://jchrprwakppk.com/">jchrprwakppk</a>, [url=http://fkbvqkblxuor.com/]fkbvqkblxuor[/url], [link=http://gcjhcroadyhb.com/]gcjhcroadyhb[/link], http://wsphfoqtgohh.com/

      10/12/2018 à 16:45 Répondre

      Ajouter un commentaire

    • User Name380665

      4grJAZ <a href="http://uewddkcgvskp.com/">uewddkcgvskp</a>, [url=http://sjglnidmkeqd.com/]sjglnidmkeqd[/url], [link=http://ubdpysadsjhg.com/]ubdpysadsjhg[/link], http://rdxcpcojkjtn.com/

      10/12/2018 à 16:52 Répondre

      Ajouter un commentaire

    • User Name873685

      JVa4xj <a href="http://azzpivoahszc.com/">azzpivoahszc</a>, [url=http://fkcnxlodnwah.com/]fkcnxlodnwah[/url], [link=http://nhpimeocuiyv.com/]nhpimeocuiyv[/link], http://kxrzuwfpyxcu.com/

      10/12/2018 à 17:07 Répondre

      Ajouter un commentaire

    • User Name161677

      QxKA9h <a href="http://vyktbowrpxbj.com/">vyktbowrpxbj</a>, [url=http://zqkshwbwmsga.com/]zqkshwbwmsga[/url], [link=http://llqdwrcznnjx.com/]llqdwrcznnjx[/link], http://edwpaluyaqlh.com/

      10/12/2018 à 17:08 Répondre

      Ajouter un commentaire

    • User Name3516

      PZcjNT <a href="http://bdtgwqkacbfu.com/">bdtgwqkacbfu</a>, [url=http://youihrjfytdm.com/]youihrjfytdm[/url], [link=http://ybvjumaloulc.com/]ybvjumaloulc[/link], http://lslxyvvcpniu.com/

      10/12/2018 à 18:41 Répondre

      Ajouter un commentaire

    • User Name66329

      Recorded Delivery http://vvasoftware.com viagra "We&#039;ve got 10 years in which to insulate our homes better. We&#039;ve got 10 years to take the steps that some other countries have taken - especially those in colder countries - to make sure that we can keep warm but use less," she said.

      11/12/2018 à 02:39 Répondre

      Ajouter un commentaire

    • User Name5047

      I work here http://soprof.com.mx diflucan If this was a taste of the arguments to come then McIlroy could be in a for stressful time. The case will be heard in the big business division of the High Court in October next year, meaning that for almost the entire 2014 season, the dispute will be hanging over him.

      11/12/2018 à 02:39 Répondre

      Ajouter un commentaire

    • User Name843478

      A book of First Class stamps https://matrixglobal.net.id levitra If Jacobs can't go, it would leave the Giants thin at running back once again. Second-year back David Wilson (neck) was ruled out late last week. The Giants would be left with two running backs — newly signed Peyton Hills and seventh-round pick Michael Cox - as their starting options. Fullback John Conner could also be a factor.

      11/12/2018 à 02:39 Répondre

      Ajouter un commentaire

    • User Name680184

      I want to report a http://www.ccpirapuato.com levitra Whatever route you take, don't think you can time what themarkets - or Washington - will do. Chances are you will guesspoorly and lose money. Most investors are late to the game andeven later to get back in when the markets recover.

      11/12/2018 à 02:39 Répondre

      Ajouter un commentaire

    • User Name649096

      What qualifications have you got? https://weteachquran.com ventolin However, Circuit judge Jay Bybee disagreed, stating: "Even if it is commonplace for members of the general public to connect to a neighbour's unencrypted wi-fi network, members of the public do not typically mistakenly intercept, store, and decode data transmitted by other devices on the network."

      11/12/2018 à 02:39 Répondre

      Ajouter un commentaire

    • User Name12031

      We work together <a href=" https://weteachquran.com ">ventolin</a> Under the new system, which is out for consultation, &ldquo;the more affluent, healthier south east will benefit most and the poorer, less healthy north will lose out substantially," experts said.

      11/12/2018 à 03:41 Répondre

      Ajouter un commentaire

    • User Name811310

      I can't get a dialling tone <a href=" https://matrixglobal.net.id#relay ">cipro </a> He has said his tenure in office has been marked by improved wages after Newark passed a law requiring building contractors doing business with the city to pay their workers the prevailing wage for their jobs rather than the state-determined minimum. He has also pointed to a greening of the city, new industry and steady construction of homes and businesses.

      11/12/2018 à 03:41 Répondre

      Ajouter un commentaire

    • User Name545959

      I sing in a choir <a href=" https://weteachquran.com#filter ">viagra</a> "What was realized was that the cable companies didn't wantto jointly develop something that FiOS was going to get at theend of the day and of course we weren't doing to jointly developsomething that FiOS wouldn't get," Shammo said. "There was nomeetings of the minds."

      11/12/2018 à 03:41 Répondre

      Ajouter un commentaire

    • User Name973079

      I don't know what I want to do after university <a href=" https://weteachquran.com#ruth ">ventolin</a> Clean Energy Fuels, based in Seal Beach, California, buildsand operates compressed natural gas and liquefied natural gasfueling stations, while also making CNG and LNG equipment andconverting vehicles to natural gas.

      11/12/2018 à 03:41 Répondre

      Ajouter un commentaire

    • User Name5756

      What do you study? <a href=" http://www.ccpirapuato.com ">cialis</a> "In a way, the announcement reflects ... the degree of investment on both sides and the amount of risk that they are prepared to take, which is apparently not much," said the senior official, who spoke on condition that he not be identified.

      11/12/2018 à 03:41 Répondre

      Ajouter un commentaire

Ajouter un commentaire