I did not know that SQL Server was the first time to use Azure SQL Database, but in SQL Server, queries across databases can be easily written by specifying the database, as shown below.
SELECT * FROM [<db_name>].dbo.test_table
However, when I try to do the same thing in Azure SQL Database, I get the following error and cannot do it.
Failed to execute query. Error: Reference to database and/or server name in '<db_name>.dbo.test_table' is not supported in this version of SQL Server.
To write cross-database queries in Azure SQL Database, the referenced table must be defined as an external table using "elastic database queries".
docs.microsoft.com [https://docs.microsoft.com/ja-jp/azure/sql-database/sql-database-elastic-query-getting-started-vertical:embed:cite]
However, it is quite time-consuming because you have to create definitions for each table one by one...
Conclusion.
In Azure SQL Database, it seems that frequently referenced tables should be placed in the same database and the database should not be used as an easy way to classify tables.
Impressions, etc.
I tried using elastic pool to see if it would work, but no luck.
Azure SQL Database is hierarchically organized as [Server]->[Database] on the portal, but the physical server seems to be a separate "database" unit.
In Azure SQL Database, the USE
command to switch databases is not available. I wondered why, but it is because the server is different for each database.
USE (Transact-SQL) - SQL Server | Microsoft Learn
I guess I can use "Azure SQL Database Managed Instance". But I think this is just a Windows PC with SQL Server installed, rather than Azure SQL Database...