2011-03-31 53 views
0

外键约束消失的方式有哪些?我有大约20个数据库,其中一些限制已经消失。外键约束消失的原因

mysql> show create table phppos_sales_items; 
+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 
| Table    | Create Table                                                                                                                                        | 
+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 
| phppos_sales_items | CREATE TABLE `phppos_sales_items` (
    `sale_id` int(10) NOT NULL default '0', 
    `item_id` int(10) NOT NULL default '0', 
    `description` varchar(30) default NULL, 
    `serialnumber` varchar(30) default NULL, 
    `line` int(3) NOT NULL default '0', 
    `quantity_purchased` double(15,2) NOT NULL default '0.00', 
    `item_cost_price` decimal(15,2) NOT NULL, 
    `item_unit_price` double(15,2) NOT NULL, 
    `discount_percent` int(11) NOT NULL default '0', 
    PRIMARY KEY (`sale_id`,`item_id`,`line`), 
    KEY `item_id` (`item_id`) 
) ENGINE=InnoDB DEFAULT CHARSET=latin1 | 
+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 
1 row in set (0.00 sec) 

mysql> show create table phppos_sales_items_taxes; 
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 
| Table     | Create Table                                                                                 | 
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 
| phppos_sales_items_taxes | CREATE TABLE `phppos_sales_items_taxes` (
    `sale_id` int(10) NOT NULL, 
    `item_id` int(10) NOT NULL, 
    `line` int(3) NOT NULL default '0', 
    `name` varchar(255) NOT NULL, 
    `percent` double(15,2) NOT NULL, 
    PRIMARY KEY (`sale_id`,`item_id`,`line`,`name`,`percent`), 
    KEY `item_id` (`item_id`) 
) ENGINE=InnoDB DEFAULT CHARSET=latin1 | 
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 
1 row in set (0.00 sec) 
+0

你可以发布'show create table '的输出吗?'在约束消失的某些表上? – vpit3833 2011-03-31 01:17:05

+0

@ vpit3833我已更新我的示例以显示其中的几个。 – 2011-03-31 01:39:04

回答

0

This可能是一个原因。详细描述在here,虽然很古老。创建表之后执行alter table可能是一个原因。你在做类似的事吗?