سؤال

I am creating few simple tables using Mysql command line. I got stock on the error number 150 while creating my Foreign Keys. Could you please help me with this one. I am kind of new to SQL. Thanks !

mysql> CREATE TABLE maintenancepersons (ServiceID INT NOT NULL AUTO_INCREMENT, 
MechanicID INT NOT NULL, 
ServiceName VARCHAR(100) NOT NULL, 
PRIMARY KEY ( ServiceID ), CarVIN INT NOT NULL, 
FOREIGN KEY ( CarVIN ) REFERENCES cars , 
CustomerID INT NOT NULL, FOREIGN KEY ( CustomerID ) REFERENCES  customers );
    ERROR 1005 (HY000): Can't create table 'dealership.maintenancepersons' (errno: 150)

لا يوجد حل صحيح

نصائح أخرى

You are missing column name in your foreign key constraint

FOREIGN KEY ( CarVIN ) REFERENCES cars.CarVIN??

and

FOREIGN KEY ( CustomerID ) REFERENCES customers.??

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top