Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to add foreign key?

I created table and added all data in it but forgot to add foreign key what to do?

There is id column in both table one table consists primary key and second table consists related data but forgot to add foreign key and when I try to print all combined data it’s not working

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

So if you created Id column in both tables and you forgotten to add foreign key then you can basically use following query

Alter table table_child add foreign key(Id) references table_parent(Id)

You can add your table names at table_child and table_parent.

Hope this help you.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading