creating foreign key..

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ramesh

    #1

    creating foreign key..

    Hi
    I have problem in creating foreign keys in mysql.
    I created the tables first. Then used the "Alter Table"
    command to associate a foreign key.
    "alter table answer add foreign key(QId) references query (QId);"
    The command was executed successfully.
    But when I used the "show create table answer" command,
    I couldnt find the created foreifn key.
    The screen output was like following..
    ------------------------------------------------------
    | answer | CREATE TABLE `answer` (
    `AId` int(11) NOT NULL default '0',
    `QId` int(11) default NULL,
    `AnsweredBy` text,
    `Answereddate` date default NULL,
    PRIMARY KEY (`AId`)
    ) TYPE=MyISAM |
    -------------------------------------------------------
    So I think the key was not created.
    Can anyone help me in this.
    I am using mysql4.1, Windows Xp home edition.
    Ramesh.
  • estevan

    #2
    Re: creating foreign key..

    You can't create a foreign key with this type of table.
    MyISAM type table don't allow you to add an extern key.
    You must use InnoDB table
    bye Estevan

    Comment

    • estevan

      #3
      Re: creating foreign key..

      You can't create a foreign key with this type of table.
      MyISAM type table don't allow you to add an extern key.
      You must use InnoDB table
      bye Estevan

      Comment

      • estevan

        #4
        Re: creating foreign key..

        You can't create a foreign key with this type of table.
        MyISAM type table don't allow you to add an extern key.
        You must use InnoDB table
        bye Estevan

        Comment

        Working...