My FAQ,最新最全的IT技术FAQ
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 未整理篇 | 技术讨论
  当前位置: > 程序开发 > 数据库开发 > Mysql
外键
作者:未知 时间:2005-09-13 23:36 出处:Blog.ChinaUnix.net 责编:My FAQ
              摘要:外键

外键关系允许把一个数据表里的一个索引声明为另一数据表里的一个索引有关联关系,还允许对外键所在的数据表设置一些操作处理方面的约束条件。数据库根据外键关系定义的规则来维护引用完性。

MySqll里的外键支持是由InnoDB数据表处理程序提供的。

create table parent

(

par_id int not null,

parimary key(par_id)    

)type = innodb;

create table child

(

par_id int not null,

child_id int not null,

primary key(par_id,child_id),

foreign key(par_id) references parent(par_id) on delete cascade

) type = innodb;

自己参考用

 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 myfaq.com.cn All rights reserved. www.myfaq.com.cn 版权所有