• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Return Index name Problem ??

 
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for reply ..
 
reply
    Bookmark Topic Watch Topic
  • New Topic