Question

Extract table name and primary key within database

  • 27 June 2019
  • 1 reply
  • 22 views

Badge +3

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


1 reply

Userlevel 4
Badge +25

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.

Reply