红联Linux门户
Linux帮助

原来mysql不支持外键,要用InnoDB才可以..

发布时间:2006-08-29 00:11:35来源:红联作者:wuhu911
原来一直用postgresql,最近接触到了mysql(5.0.20),它默认是MyISAM引擎,竟然不支持外键,后来才知道要用InnoDB引擎才能支持..

--------------------------------------------------------------------------------
create database test;
use test;
CREATE TABLE userinfo (
userid character(8) primary key,
temp character(8)

)Type=INNODB CHARACTER SET utf8;

CREATE TABLE commenttest(
userid character(8),
comment character varying(200),
foreign key(userid) references userinfo(userid) on delete cascade)
Type= INNODB CHARACTER SET utf8;


insert into userinfo values("06000017","aaaa");
insert into userinfo values("06000020","bbbb");

insert into commenttest values("06000017","cccccc");
insert into commenttest values("06000020","ddddd");
文章评论

共有 1 条评论

  1. 于 2006-10-16 22:45:05发表:

    :0)1