View Single Post

   
  #1 (permalink)  
Old 05-10-2008, 03:06 PM
Campbell, Lance
 
Posts: n/a
Default Creating a foreign key

PostgreSQL: 8.2



When you create a foreign key to a table is there an index that is
created on the foreign key automatically?



Example:

Table A has a field called ID.



Table B has a field called fk_a_id which has a constraint of being a
foreign key to table A to field ID.



Is there an index automatically created on field fk_a_id in table B when
I create a foreign key constraint?





I assume yes. But I wanted to check. I did not see it specifically
mentioned in the documentation.



I also see "CREATE TABLE / PRIMARY KEY will create implicit index" when
creating a primary key but I don't see any similar statement when
creating a foreign key.



Thanks,



Lance Campbell

Project Manager/Software Architect

Web Services at Public Affairs

University of Illinois

217.333.0382

http://webservices.uiuc.edu




Reply With Quote