Jump to content

How to select all Foreign keys in a database

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
8 replies to this topic

#1
eracha

eracha

    Newbie

  • Members
  • Pip
  • 4 posts
Hi all,

I am into writing a script for referential integrity check for mysql DB, but got stocked when I was unable to query all the Foreign keys in the DB. I will greatly appreciate if some good Samaritan can help me formulate a select query to show all foreign keys in the DB. is it even possible:rolleyes:

Many thanks in advance,
Eric

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I believe this document will help you with MySQL metadata.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
krishary

krishary

    Newbie

  • Members
  • Pip
  • 1 posts
Hey,

please take a look at this:

http: // sqlserver2000.databases.aspfaq.com/schema-how-do-i-find-all-the-foreign-keys-in-a-database [dot] html (sorry i cant post links :O :D )

This has a bit more than you think you need (bit will probably need to accomplish your task).

regards, Kris

#4
shokosugi

shokosugi

    Newbie

  • Members
  • PipPip
  • 10 posts
foreign keys? not sure i understand. but if you want to get all the "child" keys..you can use "IN" or "EXISTS" in your SQL.

you can also use MINUS.

Edited by WingedPanther, 31 October 2008 - 04:39 AM.
Double post


#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
shokosugi: foreign keys are a standard database term. Also, if a question has already been answered 4 months ago, why are you responding?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#6
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Post count, I suppose? lol
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#7
nullbyte

nullbyte

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 302 posts
This thread is very evil.

Attached Files



#8
Egz0N

Egz0N

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,034 posts

nullbyte said:

This thread is very evil.
lol :p

#9
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Lol that is a lot of views for only 5 replies.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums