cancel
Showing results for 
Search instead for 
Did you mean: 

How to get all Column names from a table in SAP HANA?

Former Member
0 Kudos

Hello frnds ,

I have a table called "HEALTH" in the SCHEMA "EC2"

I want to know that how to get all the column names of the table through query????

Regards

Qaiser Imam

Accepted Solutions (1)

Accepted Solutions (1)

rindia
Active Contributor

Hi,

In SQL editor, write the below query:

SELECT SCHEMA_NAME, TABLE_NAME, COLUMN_NAME, POSITION

FROM    SYS.COLUMNS

WHERE SCHEMA_NAME = 'SRK' AND TABLE_NAME = 'EMPLOYEE'

ORDER BY POSITION;

Here is the result:

Regards

Raj

Answers (5)

Answers (5)

former_member184768
Active Contributor

Hi,

Alternative to what Raj mentioned above, you can also look into TABLE_COLUMNS.

Regards,

Ravi

ahalya_inturi
Active Participant
0 Kudos

It helped me . TABLE_COLUMNS gives accurate results if we are looking for any specific data type from entire list of tables

edwin_dayanandhm
Explorer

I dont see the view "PUBLIC"."COLUMNS"
Like Ravindra Channe mentioned, TABLE_COLUMNS would be the best option in case we dont have all privileges.

lbreddemann
Active Contributor

I stand corrected! Ha!

The COLUMNS view has been deprecated (https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.04/en-US/a7142827fb2e4581991d3d84a3...) and the deprecation has been documented since HANA 2 SP03. Interestingly the view wasn't even documented before. Goes to show how many details get silently changed over time.

edwin_dayanandhm
Explorer

In my case I don't have access to SYS.COLUMNS table, so I used the view "SYS"."M_CS_COLUMNS"

lbreddemann
Active Contributor
0 Kudos

The "correct" view would have been "PUBLIC"."COLUMNS".

"M_CS_COLUMNS" only has the data for column store table columns and only for those that are persisted.

Also: this question had been answered more than 4 years ago. There's no need to resurrect the dead here... 😉

0 Kudos

"SYS"."M_CS_COLUMNS" is what worked for me as well. I only got error could not find table/view using Public.Columns

0 Kudos

In HANA Database, under Catalog, go to Public Synonyms folder. In this folder, you find a table called M_CS_ALL_COLUMNS. If you run the table you will get all the schema names, table names, all the column names used in all repositories(schema) in this database.

Former Member
0 Kudos

This message was moderated.