title: MySQL: How to determine foreign key relationships programmatically?
body: <p>Similar to <a href="https://stackoverflow.com/questions/85978/query-a-tables-foreign-key-relationships">this question</a> but for MySQL....</p>
  
  <p>How can I programmatically determine foreign key references in MySQL (assuming InnoDB)?  I can almost get them with:</p>
  
  <pre><code>SHOW TABLE STATUS WHERE Name = 'MyTableName';
  </code></pre>
  
  <p>...but alas, the comment column which seems to contain some of this info gets truncated so I can't rely on it.  There must be some other way...</p>
  
  <p>I'd be happy with a C API call, a SQL statement, anything--I just need something that consistently works.</p>
  
  <p>Note:  I've also considered parsing the results of a "SHOW CREATE TABLE MyTableName" statement, but I'm really hoping there's something simpler.</p>