MySQL Forums
Forum List  »  InnoDB

Re: problem adding foreign key...
Posted by: Albert Mata
Date: October 03, 2008 07:55AM

Me again. I've solved this issue. So let's see how...

In previous message I said:

In TABLE1 there is a field called VLO_COD_ACC (varchar(6)).

In TABLE2 the first two fields are...
ste_int varchar(6)
ste_id smallint(5) unsigned auto_increment
...both are not null and primary key.

I'm trying to add a foreign key this way:

alter table TABLE1 add foreign key(VLO_COD_ACC) references TABLE2(ste_int);

OK, all that I've needed is to make ste_int field unique with a sentence like:

alter table TABLE2 change ste_int ste_int varchar(6) unique;

After doing this, instruction...

alter table TABLE1 add foreign key(VLO_COD_ACC) references TABLE2(ste_int);

...works fine.

Options: ReplyQuote


Subject
Views
Written By
Posted
15336
October 03, 2008 06:01AM
Re: problem adding foreign key...
6257
October 03, 2008 07:55AM
4491
October 16, 2008 12:13PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.