Subject | Re: [firebird-support] Table name vs. field alias |
---|---|
Author | Svein Erling Tysvaer |
Post date | 2009-04-23T19:32:46Z |
Certain things fail. At least when using DB Workbench, this is not allowed:
select 1 rdb$db_key from rdb$database order by rdb$db_key
(but I don't know whether this is due to Firebird or IBO that is behind
DBW, I know IBO tend to use rdb$db_key if no key is provided)
This isn't allowed either:
select 1 from from rdb$database order by from
(logical, since aliasing is optional and FROM is the first word after,
same result if I try AS or SELECT)
I was a bit surprised that this worked:
select 1 "FROM" from rdb$database order by "FROM"
and even these worked:
select 1 "1" from rdb$database order by 1
select 1 substring from rdb$database order by substring
select 1 list from rdb$database order by list
select 1 sysdba from rdb$database order by sysdba
whereas similar statements trying SET, CASE, MIN, MAX and COUNT failed.
Generally, it seems to me that using reserved words aren't allowed,
table names are allowed and function names vary.
Though, generally, even if it is allowed to use a confusing alias, the
only good reason to use it that I can think of, is for testing Firebird
(making sure that Firebird doesn't produce a wrong result).
Set
Gabor Boros wrote:
select 1 rdb$db_key from rdb$database order by rdb$db_key
(but I don't know whether this is due to Firebird or IBO that is behind
DBW, I know IBO tend to use rdb$db_key if no key is provided)
This isn't allowed either:
select 1 from from rdb$database order by from
(logical, since aliasing is optional and FROM is the first word after,
same result if I try AS or SELECT)
I was a bit surprised that this worked:
select 1 "FROM" from rdb$database order by "FROM"
and even these worked:
select 1 "1" from rdb$database order by 1
select 1 substring from rdb$database order by substring
select 1 list from rdb$database order by list
select 1 sysdba from rdb$database order by sysdba
whereas similar statements trying SET, CASE, MIN, MAX and COUNT failed.
Generally, it seems to me that using reserved words aren't allowed,
table names are allowed and function names vary.
Though, generally, even if it is allowed to use a confusing alias, the
only good reason to use it that I can think of, is for testing Firebird
(making sure that Firebird doesn't produce a wrong result).
Set
Gabor Boros wrote:
> Hi,
>
> I know, I know.
> Just strange for me why can I use an alias which is a table name also.
> I don't have problem with this but I don't know this is a feature or a
> bug or this is an SQL Standard thing.
>
> Gabor
>
> Svein Erling Tysvaer írta:
>> Well, yes, from Firebird 2.1 it is allowed to order by alias.