原来一直用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");
于 2006-10-16 22:45:05发表:
:0)1