这是代码:
CREATE TABLE phone
(
ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
Name varchar(15) not null,
Stock VARCHAR(15) NOT NULL,
FK_manufacturerid INT NOT NULL,
INDEX (FK_manufacturerid),
FOREIGN KEY(FK_manufacturerid) REFERENCES manufacturer (manufacturerid)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
FK_osid INT NOT NULL,
INDEX (FK_osid),
FOREIGN KEY(FK_osid) REFERENCES os (osid)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
Camera varchar(15) not null,
Handset varchar(15) not null,
Screen varchar(15) not null,
Connectivity varchar(15) not null,
BatteryLife varchar(15) not null,
Memory varchar(15) not null,
Messaging varchar(15) not null,
SoundFormat varchar(15) not null,
Price int(5) not null,
Flag varchar(3) not null
)ENGINE=InnoDB
我是php的新手(我讨厌它......很多)而且我真的不知道这里有什么问题......请帮帮我:)
答案 0 :(得分:0)
This question意味着它是一个外键问题 - 你检查过所有引用的表和字段是否存在,还有需要它们的索引?看看这个问题,它可能会对你那个听起来类似的问题有所了解。
答案 1 :(得分:0)
您确定是否已创建您作为外键引用的其他表?
您作为外键引用的列必须存在于数据库和您引用的表中。
我刚刚在SQL Fiddle上使用了以下内容,它可以工作:
create table manufacturer
(
manufacturerid INT NOT NULL AUTO_INCREMENT PRIMARY KEY
) ;
create table os
(
osid INT NOT NULL AUTO_INCREMENT PRIMARY KEY
) ;
CREATE TABLE phone
(
ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
Name varchar(15) not null,
Stock VARCHAR(15) NOT NULL,
FK_manufacturerid INT NOT NULL,
FK_osid INT NOT NULL,
Camera varchar(15) not null,
Handset varchar(15) not null,
Screen varchar(15) not null,
Connectivity varchar(15) not null,
BatteryLife varchar(15) not null,
Memory varchar(15) not null,
Messaging varchar(15) not null,
SoundFormat varchar(15) not null,
Price int(5) not null,
Flag varchar(3) not null,
INDEX (FK_manufacturerid),
FOREIGN KEY(FK_manufacturerid) REFERENCES manufacturer (manufacturerid)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
INDEX (FK_osid),
FOREIGN KEY(FK_osid) REFERENCES os (osid)
ON DELETE NO ACTION
ON UPDATE NO ACTION
)ENGINE=InnoDB;