database - why FK constraint does not work in MySql -


itemprop = "text">

I have created two tables with the following constraints and ORDERITEMS:

  Changes the table OrderItems Obstacle FK_Reference_30 Include Foreign Key (Order ID) references order (order ID) on removing restrictions on update restrictions;  

If I want to delete an entry in the ORDERS table and that order ID is in the ORDERITEMS table, I should get an error or warning, I think. But I did not really get anything, I put two lines in ORDERS and some lines in ORRERITEMS. When I tried to remove all the rows in the commands, then I did it. no complaint. I am using MySQL databases with Toad for MySQL.

I think you are using MyISAM tables. / P>

If you run " run table order " you will see that it failed to record foreign key definition.

The MyISAM table does not support the foreign key, it parses MySQL syntax, but then when you use MySam, it removes it quietly. If you use Inodb tables for both order and order, then it will work better.


You must be enabled by default inodb. It will be unusual for this to be disabled. You can verify that you do this:

  mysql & Gt; Show variables like 'Has_innodb'; + --------------- + ------- + | Variable_name | Price | + --------------- + ------- + | Has_innodb | Yes. + --------------- + ------- +  

If this is true, you can specify ENGINE = INNODB When you create or ALTER one table:

  mysql> Optional table command engine = INNODB; Mysql & gt; Optional table order fuel = INNODB;  

Make sure that it is successful, show table & lt; Name & gt;

Now you can add hindrance, and it should be effective.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -