Tôi gặp lỗi khi cố gắng tạo bảng trong mysql.ERROR 1005 (HY000): Không thể tạo bảng (errno: 150)
Bất kỳ mẹo nào để giải quyết vấn đề này?
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)
);
Các Lỗi:
ERROR 1005 (HY000): Can't create table 'posinventory.stock_in' (errno: 150)
Bạn đã tạo các bảng 'sales' và' returnoutwards' với các khóa duy nhất chưa? Tất cả các bảng phải là InnoDb. – Devart
@Devart: Cảm ơn, tôi đã tìm thấy sai lầm của mình ... đó là vì biên nhận trong bảng bán hàng không phải là khóa chính ... Tôi nên tham chiếu đến cột mới với khóa chính, ví dụ: sales_no – Boon