Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2009
    Posts
    3

    Unanswered: Disable Foreign key checks.....

    Hi Friends,
    I am working with MySQL, InnoDB as a database. I will want to disable FOREIGN KEY checks. For that, I appended "?sessionVariables = FOREIGN_KEY_CHECKS = 0" to My Application's JDBC URL. i.e.,
    URL= jdbc:mysql://MyHost/MyDB?sessionVariables = FOREIGN_KEY_CHECKS = 0
    It is working fine before deployment. But after deployment it is not working( Foreign key checks are not disabled).
    If foreign keys are enabled, then the problem is: child is inserting data before the parent table. So please get rid out of this.

    Thanks for your reply,
    Sreenivasulu.A.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Why can't you insert the record into the parent table first..?
    George
    Home | Blog

  3. #3
    Join Date
    Jan 2009
    Posts
    3
    Manually I can insert the data into parent table, but My java application uses a large database. Whenever user adds a record into the database, number of queries tried to hit the database. If foreign keys are not there, then my application inserts data correctly. Because my application maintains relations in it's own fashion. When foreign keys are there, that time problem came.

  4. #4
    Join Date
    Jan 2009
    Posts
    3

    Question Java Apps and Foreign keys problem....

    Hi Friends,
    I am working with MySQL, InnoDB as a database. I will want to disable FOREIGN KEY checks through my jdbc application. For that, I appended "?sessionVariables = FOREIGN_KEY_CHECKS = 0" to My Application's JDBC URL. i.e.,
    URL= jdbc:mysql://MyHost/MyDB?sessionVariables = FOREIGN_KEY_CHECKS = 0
    It is working fine before deployment. But after deployment it is not working( Foreign key checks are not disabled).
    If foreign keys are enabled, then the problem is: child is inserting data before the parent table. So please get rid out of this.

    Thanks for your reply,
    Sreenivasulu.A.

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if you are implementing your own RI checks (seems madness in the current day and age,but each to their own) have ypu thought of using the MyISAM engine.

    or, a wild thought

    rewriting your app so it writes to parent tables first?
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    ...even if it writes only the bare-minimum information (i.e. the primary key)
    George
    Home | Blog

  7. #7
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Quote Originally Posted by tamilcnu
    If foreign keys are not there, then my application inserts data correctly.
    If it's not creating the parent records first then your application is NOT inserting data correctly. You should change your application.

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Threads merged - please do not post the same question twice!
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •