Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

foreign keys

Status
Not open for further replies.

drska

Programmer
May 21, 2004
14
HR
Whe I try to execute this code:

CREATE TABLE users(
id CHAR(10) NOT NULL PRIMARY KEY,
title VARCHAR(100),
name VARCHAR(100)
)

CREATE TABLE cars (
idcars TINYINT(4) UNSIGNED NOT NULL AUTO_INCREMENT,
made VARCHAR(100) NOT NULL,
deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (idcars),
CONSTRAINT FK_made FOREIGN KEY FK_made (made)
REFERENCES users(name)
)

i get the following error:
ERROR 1005 (HY000): Can't create table '.\mydba\cars.frm' (errno: 150)

And when I remove the constraint part, everything goes well.

I'm using MySQL 4.1.12a-nt and have created database using MySQL Administrator.

Does anyone know what seems to be the problem, and how to solve it???

Thnx.
 
Are you using InnoDB tables? That is the only table type that supports foreign keys in MySQL 4.1.
 
I've tried this and other angines, but nothing worked...!!

Any ideas???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top