cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve the list of columns of a synonym with HANA SQL

gfaerber
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,891

We need to find out, which columns a given synonym provides via HANA SQL.

HANA provides views for table_columns, view_columns, but there is nothing like synonym_columns.

What is the official SQL way in HANA to get the list of columns for a given synonym?

P.S: I have some doubts of checking to which HANA table or view a synonym refers to and then read the column information from the original artifact, because the whole point of synonyms is to hide the original object behind and make it exchangable.

View Entire Topic
Cocquerel
Active Contributor

You can run statement like this

SELECT 
	B."SCHEMA_NAME",
	B."SYNONYM_NAME",
	A."SCHEMA_NAME",
	A."TABLE_NAME",
	A."COLUMN_NAME"
FROM 
	"SYS"."TABLE_COLUMNS" AS A
	INNER JOIN
	"SYS"."SYNONYMS" AS B
	ON B."OBJECT_SCHEMA" = A."SCHEMA_NAME"
		AND B."OBJECT_NAME" = A."TABLE_NAME"
WHERE "SYNONYM_NAME" = '<YOUR_SYNONYM>';