In Oracle “AS” alias not working

和自甴很熟 提交于 2019-12-09 03:56:37

问题


Just want to know why Oracle not allowed "AS" alias in Query. In My project all queries which i returned have alias keyword "AS".

For.eg;

Select t1.id,t2.name from Table1 As t1 ,Table2 t2 
on
  t1.id =t2.id

above Query run in all Server like PostgreSQL ,Microsoft SQL server but in Oracle its Not working showing error "Command does not exists" because of alias "As". If i remove then it will run.

just want to know why Oracle Server behave like this ? i want to run query using "AS"alias name.


回答1:


While Oracle allows you to use AS when defining column aliases, it doesn't allow you to use AS when defining table aliases. It's just how Oracle works.




回答2:


You can use as(optional) for alias in column names but not for table. Using as in aliases is Microsoft standard, while ORACLE supports ANSI SQL syntax which using as in aliases is not a standard.




回答3:


According to this and this this it should be part of the ISO SQL92. Maybe Oracle did not implement it because of backward compatibility.

In Oracle keywords like "AS", "JOIN", "COMMIT", "MODEL" still can be used as object names. So you can write something like:

select J.COMMIT AS
from JOIN J;

This will select column named "COMMIT" from table named "JOIN" and the column will be aliased to "AS".



来源:https://stackoverflow.com/questions/33643163/in-oracle-as-alias-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!