cancel
Showing results for 
Search instead for 
Did you mean: 

Can we create self referencing foreign key in SAP HANA?

Former Member
0 Kudos

Hi Experts,

I am executing below commands for creating self referencing foreign key in SAP HANA.

I got the below two commands from SAP Help Portal.

CREATE TABLE SELF(A INTEGER PRIMARY KEY, B INTEGER);

ALTER TABLE SELF ADD CONSTRAINT FK_T1 FOREIGN KEY(B) REFERENCES SELF(A);

While executing above commands, the first command(i.e Create command) is working properly.

But Alter command is giving below error:

Could not execute 'ALTER TABLE SELF ADD CONSTRAINT FK_T1 FOREIGN KEY(B) REFERENCES SELF(A)' in 3 ms 76 µs .

SAP DBTech JDBC: [7]: feature not supported: cannot create foreign key constraint referencing the same table

Can anyone help me out with the above error.


I tried executing the above commands in both SAP HANA SPS 8 as well as SPS 9 but then also I am getting the above error.




Regards,

Jimit Doshi

Accepted Solutions (0)

Answers (1)

Answers (1)

xiongjun_li
Explorer
0 Kudos

Hi Doshi,

Did you work out the problem?

I encountered the same problem...

Former Member
0 Kudos

Hi Li,

Self referencing foreign keys are supported  in SAP HANA SPS 10.





Regards,

Jimit