• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Check Table's Relationships

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this is a simple question, but how do i check which table a foreign key refers to in mysql?

If i use describe tablename then i can see there is a key, but not sure what its refering to. I just want to verify i correctly mapped this in hibernate.

mysql> describe attendedlistent_userent;
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can get at this sort of data by querying the database's catalog directly (refer to the MySQL documentation for the appropriate tables) or a better way is to query the DatabaseMetaData (this way your solution is not tied to one database version).
 
Joshua Elkino
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the interested...

SHOW CREATE TABLE tbl_name
 
author
Posts: 4107
28
Google Web Toolkit Eclipse IDE Flex
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ilya,

That's database specific though, it won't work on all systems. Paul's suggestion of using the JDBC meta data classes is preferable if you're implementing the method as part of a code base. For example, if you need to check from within the application while its running.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!