如何在不使用数据库别名的情况下查询不同数据库中的表?(How to query a table from different databases without using alias of data

编程入门 行业动态 更新时间:2024-10-25 09:35:33
如何在不使用数据库别名的情况下查询不同数据库中的表?(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.bbb

Tables:

aaa : table of database Data_01 yyy : table of database Data_00

Is 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;

更多推荐

本文发布于:2023-07-31 00:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1340378.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:别名   数据库中   情况下   数据库   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!