This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Cloud Application Architecture Patterns: Designing, Building, and Modernizing for the Cloud and have Kyle Brown, Bobby Woolf and Joseph Yodor on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

retriving two primary keys

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i need to work with a table which has two primary keys.

when i use DataBaseMetaData.getPrimaryKeys() i can extract the value if theres one primary key.but what if two primary keys are there.any suggestions?
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why can't you use DatabaseMetaData.getPrimaryKeys() to deal with a primary key that has two columns? It looks like this method returns a ResultSet. Have you checked how many rows are in this result set in the situation you describe? If it has multiple rows, then each row probably represents one column in the primary key.

HTH

Layne
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shobana Sukumar:
i need to work with a table which has two primary keys.



To be precise, that's impossible. A table can have only one primary key, that's the basic fundamental meaning of "primary". You can however, have a primary key composed of more than one column. A primary key is nothing more or less than a unique index with a very special (primary) relationship to the table; most databases implement it that way.

The previous response appears to be on the right track for "how do I work with a table which has a primary key with multiple columns?".
 
reply
    Bookmark Topic Watch Topic
  • New Topic