"Paul Wallace" <[EMAIL PROTECTED]> wrote on 01/19/2005 06:50:48 PM:
> Was there a reply to this post? If so, I could have (did) missed it. Can > you please resend? > > Rgds > > Paul. > Sorry, but I never said.... (woops!) Which language I use depends on where I want to run the script and how often, and the fact that I am working in an M$ shop. I don't have any code I could share right now, maybe later (employer restrictions). What it boils down to is that you execute a SHOW CREATE TABLE query then scan the results looking for the lines that start with "FOREIGN KEY". From that point it is simple to break the line down by syntax (ON, REFERENCES, a set of parentheses) to find the child field, the parent table, and the parent field. Shawn Green Database Administrator Unimin Corporation - Spruce Pine > Shawn, what language(s) are you using to parse this? Could you share the > code? > > Thanks, > > Dave Merrill > > > > I prefer to parse the results of a "SHOW CREATE TABLE..." query. It's > > rather trivial to detect which rows in the result of that statement > > are your FOREIGN KEYS. They not only indicate which table(s) is/are > > this table's parent(s) but also which columns participate in each > > relationship. > > This technique does not rely on any particular connection library as > > the functionality is provided by MySQL itself. Once the > > INFORMATION_SCHEMA views are made available as of v5.x+ we will have > > an alternative to using the "SHOW" family of statements to extract > schema metadata. > > > > Shawn Green > > Database Administrator > > Unimin Corporation - Spruce Pine > > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] > > > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] >