Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Can we create self referencing foreign key in SAP HANA?

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

Not what you were looking for? View more on this topic or Ask a question