當我嘗試在mysql中創建表時出現錯誤。錯誤1005(HY000):無法創建表(errno:150)
解決它的任何提示?
create table stock_in(
ind int not null auto_increment,
itemcode varchar(10) not null,
quantity int not null,
description text not null,
sales_ref int not null default -1,
return_outwards_ref int not null default -1,
stock_in_receipt_ref int not null default -1,
date text not null,
time text not null,
username text not null,
foreign key (sales_ref) references sales (receiptno),
foreign key (return_outwards_ref) references returnoutwards(ind),
primary key (ind)
);
的錯誤:
ERROR 1005 (HY000): Can't create table 'posinventory.stock_in' (errno: 150)
您是否使用唯一鍵創建了'sales'和'returnoutwards'表?所有表格必須是InnoDb。 – Devart
@Devart:謝謝,我發現我的錯誤......這是因爲salesno中的receiptno不是主鍵......我應該將它引用到具有主鍵的新列,例如sales_no – Boon