How to configure a foreign key in SQL Azure?

How to configure a foreign key in SQL Azure?

Now I have a database on an Azure system.

The tables in the database have the intended use, so there is one main, logically centralized table, and then there are several tables, each of which describes a column in the main table. For example, if I have an age classification column in the main table, I may have a separate table that lists some age classification categories (like a row) and some related index. Then the index from the age classification table will be used as a reference in the main table.

What is a foreign key? Is there any way in SQL Azure to link these indexes?

+4
source share
1 answer

yep is this foreign key.

Perhaps the easiest way is to use t-sql in the SSMS query window

alter table MyTable add constraint MyTable_MyColumn_FK FOREIGN KEY ( MyColumn ) REFERENCES MyOtherTable(MyOtherIDColumn) 

(from: How to create a foreign key in SQL Server? )

SQL Azure is in some respects different from other SQL servers, but not in terms of this simple command.

I found Azure SQL Migration Wizard invaluable for converting 'normal' sql to Azure SQL.

+9
source

Source: https://habr.com/ru/post/1433750/


All Articles