• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Return Index name Problem ??

 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, good day, as showing below code was my testing code to get index name from respective table

description :

- there are 5 tables :newcampaign,newcompany,newcompetitor,newcomplaint,newtable2

- only newtable2 have index with named newindex

- newcampaign have a primary key , the rest table don't not have primary key

problem:
when the following code run, it suppose to show me the result only "index:newindex" , but as shown in below result, it give me few "index:PRIMARY" ..anyone why is it so ?

for your info : if i run the SQL statement in MYSQL with "show index from newcampaign" , it do give me one record ..even i didn't set index for newcampaign table but only primary key



result :

index:PRIMARY
index:PRIMARY
index:PRIMARY
index:PRIMARY
index:newindex


thank you very much for your time and your help is highly appreciated

[edited to disable smilies in :PRIMARY]
[ December 20, 2004: Message edited by: Jeanne Boyarsky ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alvin,
Every table has an implicit primary key if you don't define one explicitly. The key just happens to be composed of all the fields in the table. This isn't useful, but it is what the database considers the key.

As you are aware, many databases automatically give you an index on the primary key. This happens whether you define a primary key or not.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just to add.
some databases give you indices(indexes) on unique constraints as well.
hence, we need not make indexes for primary key and unique constraint columns.

cheers.
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for reply ..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic