Are indexes auto created when you create a foreign key?

This is a discussion on Are indexes auto created when you create a foreign key? within the MySQL Database forums, part of the Database Forums category; When you create a foreign key, is an index also created for the same column? I have searched around for ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-21-2008
chris
 
Posts: n/a
Default Are indexes auto created when you create a foreign key?

When you create a foreign key, is an index also created for the same
column? I have searched around for the answer on this and I have
gotten conflicting answers.

They way mysql works, is this the same for all databases?

Thanks for the help.
Reply With Quote
  #2 (permalink)  
Old 04-21-2008
Peter H. Coffin
 
Posts: n/a
Default Re: Are indexes auto created when you create a foreign key?

On Mon, 21 Apr 2008 09:05:23 -0700 (PDT), chris wrote:
> When you create a foreign key, is an index also created for the same
> column? I have searched around for the answer on this and I have
> gotten conflicting answers.


Depends on the version. In Mysql version 4.1.2 and later, the InnoDB
engine will build the index automatically. Prior versions needed the
index to be created beforehand, and then specified when you're actually
declaring the FK.

> They way mysql works, is this the same for all databases?


Yes, the same for all databases, because this is version-dependant
behavior.

--
I think I'd like to see a Simpsons episode starting up with Bart Simpson
writing "I will not attempt to undermine the Usenet Cabal".
-- J. D. Falk
Reply With Quote
  #3 (permalink)  
Old 04-21-2008
chris
 
Posts: n/a
Default Re: Are indexes auto created when you create a foreign key?

On Apr 21, 10:49*am, "Peter H. Coffin" <hell...@ninehells.com> wrote:
> On Mon, 21 Apr 2008 09:05:23 -0700 (PDT), chris wrote:
> > When you create a foreign key, is an index also created for the same
> > column? *I have searched around for the answer on this and I have
> > gotten conflicting answers.

>
> Depends on the version. In Mysql version 4.1.2 and later, the InnoDB
> engine will build the index automatically. Prior versions needed the
> index to be created beforehand, and then specified when you're actually
> declaring the FK.
>
> > They way mysql works, is this the same for all databases?

>
> Yes, the same for all databases, because this is version-dependant
> behavior.
>
> --
> I think I'd like to see a Simpsons episode starting up with Bart Simpson
> writing "I will not attempt to undermine the Usenet Cabal".
> * * * * * * * -- J. D. Falk


Hey Peter,

Thanks for clearing that up.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:35 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0