Given different data sources I would like to find out all foreign keys inside the database. The DB can be anything from SQLite to SQL Server and Oracle. Is there a generic way to do it? May be an ORM might be helpful?
There are some fine scripts on SO, like this one. But this is SQL Server specific and I want to research the generic nature of the problem.
The only hope you have to be RDBMS agnostic is to use the
INFORMATION_SCHEMAviews, which should be supported by any reasonably ANSI-SQL-compatible database system.See this SO question on how to find the referential integrity constraints using
INFORMAITON_SCHEMA. Queries like that should work onOracle,MySQL and PostgreSQL etc. – but most likely not in SQLite (not ANSI compatible enough, as far as I can remember)