如何在不使用数据库别名的情况下查询不同数据库中的表?(How to query a table from different databases without using alias of database?)
我正在从两个数据库表中检索数据,我包括以下查询来实现它。
在存储过程中查询 :
--Some query here... LEFT OUTER JOIN aaa c ON l.IDNo = c.LogonIDNo INNER JOIN Data_00.dbo.yyy A ON C.MacCusNo = A.Cus_no LEFT OUTER JOIN abc T ON A.xyz = T.bbb表格 :
aaa : table of database Data_01 yyy : table of database Data_00有没有办法从两个数据库表中检索数据而不使用'Data_00.dbo.yyy'我只想使用yyy而不是它。
I am doing task of retrieving the data from both database tables,I included following query to achieve it.
Query in stored procedure:
--Some query here... LEFT OUTER JOIN aaa c ON l.IDNo = c.LogonIDNo INNER JOIN Data_00.dbo.yyy A ON C.MacCusNo = A.Cus_no LEFT OUTER JOIN abc T ON A.xyz = T.bbbTables:
aaa : table of database Data_01 yyy : table of database Data_00Is there any way to retrieve the data from both the database tables without using 'Data_00.dbo.yyy' I want to use only yyy instead of it.
最满意答案
我假设你正在使用SQL Server。
是的,你可以创建一个同义词。 同义词允许您指定访问各种数据库对象的简写名称,而不管它们是否与同义词规则位于同一数据库中。
USE Data_01; CREATE SYNONYM yyy FOR Data_00.dbo.yyy;I'll assume you're using SQL Server.
Yes, you can create a synonym. Synonyms allow you to specify a shorthand name for accessing various database objects, whether they reside in the same database as the synonym rule or not.
USE Data_01; CREATE SYNONYM yyy FOR Data_00.dbo.yyy;更多推荐
发布评论