Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dukebound85

macrumors Core
Original poster
Jul 17, 2005
19,218
4,342
5045 feet above sea level
amyone know why I am getting this error? I can't seem to have the foreign key work
 

Attachments

  • IMG_5830.PNG
    IMG_5830.PNG
    645.1 KB · Views: 190
Please copy and paste the complete actual text from the Terminal window.

1. Your photo cuts off a significant part of the error message. Details are important in programming.

2. Which SQL app or command-line tool is this appearing in? Again, details are important.

3. The thread title says "error 150", but the picture shows "ERROR 1005" and "errno: 150". Those are different things.

errno is an error variable, and the values it can take on are usually documented. See 'man 2 intro' (cmd to type in Terminal) for a discussion of errno and the typical system-provided values. 150 is well above that range, which suggests your SQL engine or app or tool is setting errno to that value. You'd have to refer to the programming manual to find out what an errno of 150 means. You might also find that the code in parens, i.e. HY1000, has some meaning for decoding the error.

EDIT

If you're using MySQL, try this syntax:
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)

Pulled from this page:
https://www.w3schools.com/sql/sql_foreignkey.asp

Found by googling: sql foreign key syntax


If you're using sqliteN, it has the same syntax:
https://sqlite.org/foreignkeys.html

Found by googling: sqlite foreign key syntax
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.