Question about ERROR 1005 (HY000)

Newbie to MySQL, I don't know why it shows "ERROR 1005 (HY000): Can't create table 'test.project' (errno: 150)". I tried index it, checked engine.

Please give some help.

drop table driver;
drop table project;
drop table plant;
drop table customer;

create table customer(
	customer_ID	numeric(3),
	customer_name text	not null,
	location text,
	primary key (customer_ID)

create table plant(
	plant_name	text,
	plant_type	text,
	process_unit	text,
	plant_customer_ID numeric(3) not null,
	primary key (plant_name(8)),
	foreign key (plant_customer_ID) references customer(customer_ID)
)engine = innodb;

create table project(
	plant_name text,
	project_number	text,
	primary key (project_number(8)),
	foreign key (plant_name(8)) references plant(plant_name)
)engine = innodb;

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

A Google search on MySQL errno 150 indicates a foreign key problem in
creating your project table.

I see in your command this clause:
foreign key (plant_name(8)) references plant(plant_name)

This looks incorrect in that you include "(8)" in the clause. It should be more
correctly like this:

foreign key (plant_name) references plant(plant_name)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zzl630Author Commented:
Hey Wolfgang 93,

Thanks for your reply.

Yes, I changed that before. Then it shows  ERROR 1170 (42000): BLOB/TEXT column ‘plant_name’ used in key specification without a key length.

Just moved from Oracle to MySql, confused here.

zzl630Author Commented:
I guess I figured out the problem by this link
Thanks for your help,Wolfgang 93.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.