![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Apart from setting @@FOREIGN_KEY_CHECKS to zero, is there any other setting or circumstance where MySQL will allow to insert invalid IDs in columns subject to foreigh key restrictions? I'm trying to diagnose why I'm finding a large number of rows that point to non-existing parent records in the database of a PHP driven app. |
#3
| |||
| |||
|
|
In article<jcn44l$6nn$1 (AT) dont-email (DOT) me>, Álvaro G. Vicario<alvaro.NOSPAMTHANX (AT) demogracia (DOT) com.invalid> wrote: Apart from setting @@FOREIGN_KEY_CHECKS to zero, is there any other setting or circumstance where MySQL will allow to insert invalid IDs in columns subject to foreigh key restrictions? I'm trying to diagnose why I'm finding a large number of rows that point to non-existing parent records in the database of a PHP driven app. What type (engine) are the tables? AFAIK, only InnoDB will enforce foreign key constraints. |
#4
| |||
| |||
|
|
El 19/12/2011 11:42, Tony Mountifield escribió/wrote: In article<jcn44l$6nn$1 (AT) dont-email (DOT) me>, Álvaro G. Vicario<alvaro.NOSPAMTHANX (AT) demogracia (DOT) com.invalid> wrote: Apart from setting @@FOREIGN_KEY_CHECKS to zero, is there any other setting or circumstance where MySQL will allow to insert invalid IDs in columns subject to foreigh key restrictions? I'm trying to diagnose why I'm finding a large number of rows that point to non-existing parent records in the database of a PHP driven app. What type (engine) are the tables? AFAIK, only InnoDB will enforce foreign key constraints. Sorry for the omission. I should have mentioned that foreign keys are working properly (you can't insert values that don't exist in parent table and you get cascaded updates and deletions where set). That's why I'm scratching my head when I see invalid data now and then. |
#5
| |||
| |||
|
|
Apart from setting @@FOREIGN_KEY_CHECKS to zero, is there any other setting or circumstance where MySQL will allow to insert invalid IDs in columns subject to foreigh key restrictions? |
#6
| |||
| |||
|
|
"Alvaro_G._Vicario" <alvaro.NOSPAMTHANX (AT) demogracia (DOT) com.invalid> wrote: Apart from setting @@FOREIGN_KEY_CHECKS to zero, is there any other setting or circumstance where MySQL will allow to insert invalid IDs in columns subject to foreigh key restrictions? None I'm aware of. Could the orphan records have existed *before* the FK constraint was added? Adding an FK does not check existing data. |
|
Neither does re-enabling @@FOREIGN_KEY_CHECKS |
#7
| |||
| |||
|
|
Axel Schwenke <axel.schwenke (AT) gmx (DOT) de> wrote: Adding an FK does not check existing data. Are you sure about that? |
![]() |
| Thread Tools | |
| Display Modes | |
| |