Skip to main content
Question

Extract table name and primary key within database

  • June 27, 2019
  • 1 reply
  • 224 views

boubcher
Contributor
Forum|alt.badge.img+11

Hello there

I am looking to extract tables name and primary keys of a database in order to use it on the other workspace

Any idea, please

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

mark2atsafe
Safer
Forum|alt.badge.img+59

I don't know if you want to automate this or just get a list, but databases usually include a system table that lists all user tables. 

For example in SQL Server this command should return a list of tables:

SELECT TABLE_NAME 
FROM <DATABASE_NAME>.INFORMATION_SCHEMA.TABLES 
WHERE TABLE_TYPE = 'BASE TABLE'

You could put that into FME in a SQLCreator transformer, and then you'll get a list of tables each as a separate FME feature.

I don't know what else is stored in that table, but I expect primary key would be another piece of available information.