I would like to query a system-table in sap-hana db to extract information regarding foreign-keys. There are the 'Indexes' and 'Index_columns' system tables, but I only see the 'Constraint' column to contain 'Primary key' and '?' values, but not a foreign-key value. Any help regarding this highly appreciated.
1 Answer
Check system table REFERENTIAL_CONSTRAINTS:
select * from "REFERENTIAL_CONSTRAINTS"
That's where foreign keys are listed - just as it can be found in the system documentation.
-
Are this real foreign key constraints? Because there are nearly no entries. Commented Aug 9, 2016 at 18:43
-
Well, does the database you are using, actually have foreign keys? In SAP NetWeaver DBs, you typically won't find any of those.– Lars Br.Commented Aug 9, 2016 at 22:07
-
It's HANA. And I exactly executed the piece of code you provided. But there is no entry with SAP_ECC. Commented Aug 9, 2016 at 22:18
-
1Ok, so you're looking at an SAP ECC system? In that case, as mentioned, don't expect to find any foreign keys on the DB level. SAP doesn't implement them on DB level.– Lars Br.Commented Aug 10, 2016 at 3:38
-
Thanks :) Do you have any references for this? I'm interested in further explanations and the reasons for this. Commented Aug 10, 2016 at 4:55