消失在phpMyAdmin中的外键 [英] Disappearing Foreign Keys in phpMyAdmin
本文介绍了消失在phpMyAdmin中的外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
创建一个新的表内mysql的,我试图添加一个外键约束到一个字段。 TABLE`onlineorder`(
`receipttid` varchar(10)NOT NULL default'',
`delivereddate` date default NULL,
`cid` int(10)NOT NULL,
'card#'int(10)默认NULL,
'expire`日期默认NULL,
PRIMARY KEY(`receipttid`),
FOREIGN KEY(收据标签)REFERENCES购买
)ENGINE = MyISAM DEFAULT CHARSET = latin1;
但是,创建后,我进入phpMyAdmin并导出表。 (
$ b
CREATE TABLE`onlineorder`(
`receipttid` varchar(10) NOT NULL默认为'',
`delivereddate`日期默认为NULL,
`cid` int(10)NOT NULL,
`card#`int(10)default NULL,
`expire` date默认为NULL,
PRIMARY KEY(`receipttid`)
)ENGINE = MyISAM DEFAULT CHARSET = latin1;
是否phpMyAdmin除掉外键或者我在这里做错了什么?
dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.htmlrel =noreferrer> http://dev.mysql.com/doc/refman/5.0/en/innodb- foreign-key-constraints.html
I am creating a new table inside mysql and I am trying to add a foreign key constraint to one of the fields.
CREATE TABLE `onlineorder` ( `receiptid` varchar(10) NOT NULL default '', `delivereddate` date default NULL, `cid` int(10) NOT NULL, `card#` int(10) default NULL, `expire` date default NULL, PRIMARY KEY (`receiptid`), FOREIGN KEY (receiptid) REFERENCES purchase ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
However, after it creates it, I go into phpMyAdmin and export the table. and it seems like the foreign key constraint has disappeared.
CREATE TABLE `onlineorder` ( `receiptid` varchar(10) NOT NULL default '', `delivereddate` date default NULL, `cid` int(10) NOT NULL, `card#` int(10) default NULL, `expire` date default NULL, PRIMARY KEY (`receiptid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Does phpMyAdmin get rid of foreign keys or am I doing something wrong here?
解决方案
You need to use the InnoDB engine to have foreign keys.
Ref: http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html
这篇关于消失在phpMyAdmin中的外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文