我应该如何解释“从a.b@a.c.d aliasRefForMe中选择不同的aliasRefForMe.field1", [英] How should I interpret "Select Distinct aliasRefForMe.field1 From a.b@a.c.d aliasRefForMe"
问题描述
Oracle模式表参考a.b@c.d.e aliasRefForMe
-这是什么?
Oracle schema table reference a.b@c.d.e aliasRefForMe
- what is this?
不确定这对Oracle select语句意味着什么.有人知道吗?
Not sure what this means for an Oracle select statement. Anybody know?
Select Distinct aliasRefForMe.field1 From a.b@a.c.d aliasRefForMe
两个问题:
-
Select ... From a.b.c
是在Oracle中的表之前表示一个模式和一个子模式吗?子模式甚至存在吗?
Does
Select ... From a.b.c
mean a schema and a sub schema before the table in Oracle? Do sub schemas even exist?
a.b@a.c.d aliasRefForMe中的@是什么?
What is the @ for in a.b@a.c.d aliasRefForMe?
请注意,出于公司隐私的考虑,我更改了表格/方案名称.
Note that I changed the table/schema names for company privacy.
推荐答案
The Oracle documentation includes a section on Syntax for Schema Objects and Parts in SQL Statements.
其中:
- object是对象的名称.
- schema是包含对象的架构...
- part是对象的一部分.该标识符使您可以引用模式对象的一部分,例如表的列或分区...
- dblink仅在使用Oracle数据库分布式功能时适用.这是包含对象的数据库的名称. dblink限定符使您可以引用本地数据库以外的数据库中的对象...
- object is the name of the object.
- schema is the schema containing the object...
- part is a part of the object. This identifier lets you refer to a part of a schema object, such as a column or a partition of a table...
- dblink applies only when you are using the Oracle Database distributed functionality. This is the name of the database containing the object. The dblink qualifier lets you refer to an object in a database other than your local database...
所以在您的示例中
Select Distinct aliasRefForMe.field1 From a.b@a.c.d aliasRefForMe
-
@a.c.d
是数据库链接,其中a
部分是远程数据库名称,而c.d
是数据库域-可能是计算机名和/或您的公司域. 详细了解数据库链接和全局数据库名称和@a.c.d
is a database link, where thea
part is the remote database name and thec.d
is the database domain - possibly either a machine name and/or your company domain. Read more about database links and global database names and how they are formed.aliasRefForMe
is a table alias (or correlation name), which is just to make it easier to refer to that table elsewhere in your query.field1
是该远程数据库中该表中的列的名称.field1
is the name of a column in that table on the remote database.没有表别名,查询将是:
Without the table alias the query would be:
Select Distinct a.b.field1@a.c.d From a.b@a.c.d
...在这个人为设计的示例中,实际上较短,但具有真实对象名称的对象将比原始对象名称长,并且更难于阅读和理解.尽管在这种情况下,只需查询一个表,您就可以摆脱:
... which in this contrived example is actually shorter, but with real object names would be longer than the original, and harder to read and understand. Although in this case, with only a single table being queried, you could get away with just:
Select Distinct field1 From a.b@a.c.d
因为对
field1
的来源没有任何歧义;但是排位赛是一个好习惯,因为这样可以节省时间和以后的困惑.as there is no ambiguity about where
field1
is coming from; but qualifying everything is a good habit as it saves time and confusion later.当有多个长名称的表时,表别名更有用-它们使选择列表和连接条件都更短.不过,如果别名是有意义的名称,则会有所帮助.
Table aliases are even more useful when there are multiple tables with long names - they make both the select list and join conditions shorter. It helps if the aliases are meaningful names though.
这篇关于我应该如何解释“从a.b@a.c.d aliasRefForMe中选择不同的aliasRefForMe.field1",的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!