cancel
Showing results for 
Search instead for 
Did you mean: 

Column name and Table Name can they be same?

Former Member
0 Kudos

Hi Experts,

I am learning on Join types is SAP HANA Modeling.

Created a "State" table with State and Sname as below

State

State     Sname

MI          MICHIGAN

AL          ALABAMA

Now when I am writing a SQL SELECT Sname from "State" , It is working fine. But when I give

Select State from "State" it is saying invalid column name.

So if table name and Column cannot be the same why is it allowing while creating the table.(I uploaded a csv file data and created this table)

Am I missing some settings/some thing some where. Searched for this error but didn't get any answer. hence posting it.

Thanks in Advance.

Regards,

Archana

Accepted Solutions (1)

Accepted Solutions (1)

muthuram_shanmugavel2
Contributor
0 Kudos

Hi Archana,


Table_Name and It's Column_Name could be same. No Issues on that.


HANA Column names are case sesitive. You are getting invalid column name error becasue of it.

Upper Case Column Names:


If tables have been created using below queries,

Column names will be in Upper case [This is recommended format].

i.  Create Column table  STATE (STATE Varchar(2),  SNAME Varchar(10));

ii. Create Column table  STATE (State Varchar(2),  SName Varchar(10));


Both  Select Queries will be working fine in this case.

i. Select STATE, SNAME From STATE;

ii. Select State, SName From STATE;


Lower Case Column Names:

If table have been created below query (Column names mentioned in double quotes),

Column name will be in Lower case.

Create Column table  STATE ("State" Varchar(2),  "SName" Varchar(10));


i. Select "State", "SName" From STATE --> Will work

ii. Select State, SName From STATE --> Invalid column Name Error as It looks Upper case column names.


Regards,

Muthuram



Answers (2)

Answers (2)

Former Member
0 Kudos

Thank You Arden and Muthuram.

I get it.

It worked when I gave the query as

select "State" from "State"

Regards,

Archana

muthuram_shanmugavel2
Contributor
0 Kudos

Hi Archana,

Check your Table definition.

Whether Column names are displayed in Uppercase or Lowercase,

Lower case column names should be mentioned in double quotes

Other wise it will treat as Upper case.

Regards,

Muthuram

Former Member
0 Kudos

Hi Archana

I maybe wrong but I think it should still work, you could try a few variations as per below

select "STATE" from "STATE"

select "STATE" from "YOUR_SCHEMA_NAME"."STATE"

Let me know how you get on

Regards

Arden