You have several problems.
Both tables have duplicate keys.

You don't have a (c_id) key in table2 to add a constraint to.

William Hambleton wrote:

I can't seem to be able to create foreign keys. Here are my create procedures and the error I am receiving.

CREATE TABLE `test1` (
 `a_id` smallint(6) NOT NULL default '0',
 PRIMARY KEY  (`a_id`),
 KEY `a_id` (`a_id`)
) TYPE=InnoDB;

CREATE TABLE `test2` (
 `b_id` smallint(6) NOT NULL default '0',
 `c_id` smallint(6) NOT NULL default '0',
 PRIMARY KEY  (`b_id`),
 KEY `b_id` (`b_id`)
) TYPE=InnoDB;

mysql> alter table test2 add constraint
   -> FOREIGN KEY (c_id) REFERENCES test1 (a_id);

ERROR 1005: Can't create table './inventory/#sql-267_4.frm' (errno: 150)

This seems very simple. Is there a problem in my alter statement?


William Hambleton Humana Inc. Technical Analyst Pho. 502.580.1657 Fax. 502.580.1288

- - - - - - - - - - - - - - - - - - - -
The information transmitted is intended only for the person or entity to which it is addressed and may contain CONFIDENTIAL material. If you receive this material/information in error, please contact the sender and delete or destroy the material/information.
- - - - - - - - - - - - - - - - - - - -





-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to