If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > "SHOW KEYS FROM" - can I get the source table name?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-17-09, 13:19
Spudhead Spudhead is offline
Registered User
 
Join Date: Jan 2002
Posts: 189
"SHOW KEYS FROM" - can I get the source table name?

... umm.... as it says, really.

It gives me a list of FK's but not the names of the tables on the other end of those FK's.

Presumably I'm being a plank and there's a very good reason why it doesn't tell you that, because I'd have thought that the name of the table on the other end of the relationship was one of the first things you'd want to know about a given relationship.

Reply With Quote
  #2 (permalink)  
Old 02-17-09, 13:57
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Code:
SHOW CREATE TABLE shoutout
this will show the foreign key syntax, e.g.
Code:
CONSTRAINT w00t_fk
    FOREIGN KEY ( w00t )
      REFERENCES w00ts ( id )
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-18-09, 06:06
Spudhead Spudhead is offline
Registered User
 
Join Date: Jan 2002
Posts: 189
Thanks - but is there a way that would give me the data in a bunch of fields, rather than one long SQL string that I'm gong to have to somehow parse in my application code?
Reply With Quote
  #4 (permalink)  
Old 02-18-09, 06:34
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
Check out the INFORMATION_SCHEMA
Reply With Quote
  #5 (permalink)  
Old 02-18-09, 06:59
Spudhead Spudhead is offline
Registered User
 
Join Date: Jan 2002
Posts: 189
Awesome. The KEY_COLUMN_USAGE table contains what I need, but it's in a different schema to everything else. So I'd need a different ADODB connection to actually do anything with it.

I don't think I'm going to be able to do this
Reply With Quote
  #6 (permalink)  
Old 02-18-09, 08:38
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by Spudhead
...to somehow parse in my application code?
you never said you wanted to automate this

that information is pretty pertinant to a satisfactory answer, wouldn't you say

Q: i need some water
A: here's a cup of water for you
Q: wrong! i need water to float my yacht!!!
A:
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 02-18-09, 11:25
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
Quote:
Originally Posted by Spudhead
Awesome. The KEY_COLUMN_USAGE table contains what I need, but it's in a different schema to everything else. So I'd need a different ADODB connection to actually do anything with it.
I don't understand this (but I have no experience with ADODB though)

Can't you simply run:
Quote:
SELECT *
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
from within your regular connection?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On