我用你的句法试了下,没有错误!你再写一次,注意一下标点,空格之类。
从你出错的信息"ERROR 1005 (HY000): Can't create table '.\testdb\#sql-260_3.frm' (errno: 150)"
来看,说的是外键声明发生了错误。
从你出错的信息"ERROR 1005 (HY000): Can't create table '.\testdb\#sql-260_3.frm' (errno: 150)"
来看,说的是外键声明发生了错误。
代码如下:
/*==============================================================*/
/* DBMS name: MySQL 4.0 */
/* Created on: 2005-10-28 12:21:16 */
/*==============================================================*/
drop table if exists country;drop table if exists person;/*==============================================================*/
/* Table: country */
/*==============================================================*/
create table country
(
id varchar(20) not null,
name varchar(40),
primary key (id)
)
type = InnoDB;/*==============================================================*/
/* Table: person */
/*==============================================================*/
create table person
(
id varchar(30) not null,
cou_id varchar(20),
primary key (id)
)
type = InnoDB;/*==============================================================*/
/* Index: "Reference_1_FK" */
/*==============================================================*/
create index Reference_1_FK
(
cou_id
);alter table person add constraint FK_Reference_1 foreign key (cou_id)
references country (id) on delete restrict on update restrict;