Oracle과 SQL 표준
BNF Grammars for SQL-92, SQL-99 and SQL-2003

Oracle을 만지게 되면서 습관적으로 실수하는 항목이 있는데, table alias 앞에 'AS'를 붙이는 것이다.


MSSQL을 써오면서, column명과 table명에 alias를 설정할 때, 모두 'AS'를 붙여서 사용해 왔었다.

그리고, 어쩌다보니 oracle을 사용하게 되었는데, MSSQL에서 사용하던 습관이 약간?의 문제를 일으켰다.


SQL-99SQL-2003의 경우 그 문법에서 table alias를 설정할 때, <table_name> [[AS] <alias_name>]으로 되어있어, 'AS'를 생략하거나 추가할 수 있는것에 비해, SQL-92의 경우 <table_name> [<corelation-name>]으로 되어있어, 'AS'를 사용할 수 없도록 되어있다.

Oracle의 경우 SQL-92에 기초하고 있기 때문에. Table에 alias를 사용할 때에는 'AS'를 기록하여서는 안된다.
(Column alias의 경우 SQL-92에서부터 <value_expression> [[AS] <column_name>]으로 되어있기때문에 'AS'를 사용하여도 된다.)

SQL is a special-purpose language, sometimes described as a relational language, which can be used with a database for a number of different purposes. SQL can be considered a standard language, with some qualification. There are two significant standards, SQL-92 and SQL-99. Most database vendors, including Oracle, are largely compliant with SQL-92. SQL-99 greatly extends the scope of SQL, introducing new features such as persistent modules and multidimensional analytical capabilities. Most database vendors are largely compliant with the core features of SQL-99, but not the new features. This core compliance allows them to claim that they are compliant with SQL-99, even though this is virtually the same as being compliant with SQL-92. To confuse things further, most vendors, including Oracle, also have extensions to standard SQL, which are sometimes unavoidable. SQL commands can generally be grouped into a number of general categories, according to their purpose:


지금까지는 항상 MS의 제품/기술들이 표준을 안지키고, 표준에 느린 반응을 한다고 욕해왔는데, 이 부분에서는 MS가 Oracle보다 빠른 행보를 보인듯 하다. (물론 다른 query들을 다 비교해 본것이 아니기 때문에, 정확하게 그렇다고는 할 수 없겠지만, table alias에서만은 그렇다.)
by 나무귀신 | 2007/05/09 01:23 | tech | 트랙백(1) | 덧글(2)
트랙백 주소 : http://schoolor.egloos.com/tb/3388304
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]
Tracked from 행복의 세잎 클로버 at 2009/07/02 13:52

제목 : Oracle Table Alias ㅡ,.ㅡ
젠장... 먼가 싶었다. 결국... 오라클이 남들에 비해 늦게 표준을 적용한다는... ㅋㅋ 찾아보기 전에 강사에서 물어봤더니... 단호하게 table alias는 'as' 붙이면 안됩니다. 그러는거다. "왜요?" ... " 그냥 안됩니다." "원래 SQL에는 as를 쓸수 있고, 생략이 가능한 걸고 알고 있는데... 오라클에서만 먼가 다른건가요?"..." table alias 사용시에는 'as' 쓰면 안됩니다." "... 네..." 젠장. 그래서......more

Commented by 이라나이 at 2007/05/09 13:03
AS 써야되..난 안쓰면 못해 -_- 쓰게 해주..
Commented by 나무귀신 at 2007/05/09 18:57
어차피 oracle 안쓰시잖아요-_- MSSQL에서는 상관없어요.

:         :

:

비공개 덧글



< 이전페이지 다음페이지 >