ODBC Schema - How Do I Find Relationships?

I am currently working on a project that requires fetching a database schema through an ODBC connection. Mostly because the source could be an Access database, SQL Server, Oracle, etc. With this, I recreate the client schema in the SQL database.

Everything works fine, but I canโ€™t find a way to restore relations between the tables, and I couldnโ€™t find anything on MSDN about this. If this cannot be done, I need to know another common way to do this.

Thanks in advance for any answers.

+4
source share
1 answer

If you use the ODBC API directly, you can use the SQLForeignKeys API to do this . However, since you are using OdbcConnection objects, it would be a painful process to use the API for this one task. Well, for that matter, using the ODBC API directly for anything is a lot of work.

Edit I suggested the option to use OdbcConnectionGetSchema with 'ForeignKeys' as the name of the collection. However, I studied this and, unfortunately, OdbcConnection does not seem to support this collection.

Thus, in addition to using SQLForeignKeys directly (or for database-specific calls), it seems that ODBC is not going to provide a simple route for collecting this information in general. If someone can give an answer with a good mechanism for this, I will delete this answer, since its only value at the moment is to indicate that I do not know how to find the information in a clean way.

+3
source

Source: https://habr.com/ru/post/1341385/


All Articles