By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,510 Members | 1,153 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,510 IT Pros & Developers. It's quick & easy.

Question on Alias

P: n/a
Hi,

An alias is an alternate name for a table or a view. Now, suppose I
create an alias on a non existent table in the control centre , it
gives me a warning but it still creates the alias for an object which
is not even present.

create alias newalias for nonexistenttable;

[IBM][CLI Driver][DB2/NT] SQL0403W The newly defined alias
"TARIQ.newalias" resolved to the object "TARIQ.nonexistenttable" which
is
currently undefined. SQLSTATE=01522

My question is when an alias points to some thing which is present in
the database,
why does it allow to CREATE the alias when the object is not present?

Regards,
rAinDeEr

Jun 22 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"rAinDeEr" <ta**********@gmail.com> wrote in message
news:11**********************@y41g2000cwy.googlegr oups.com...
Hi,

An alias is an alternate name for a table or a view. Now, suppose I
create an alias on a non existent table in the control centre , it
gives me a warning but it still creates the alias for an object which
is not even present.

create alias newalias for nonexistenttable;

[IBM][CLI Driver][DB2/NT] SQL0403W The newly defined alias
"TARIQ.newalias" resolved to the object "TARIQ.nonexistenttable" which
is
currently undefined. SQLSTATE=01522

My question is when an alias points to some thing which is present in
the database,
why does it allow to CREATE the alias when the object is not present?

Regards,
rAinDeEr


That is a design decision. One advantage is that if you drop a table and
recreate it, the alias does not need to be recreated.
Jun 22 '06 #2

P: n/a

Hi Mark,
That is a design decision. One advantage is that if you drop a table and
recreate it, the alias does not need to be recreated.


That doesnt answer my question. I dont have any table/view but still I
am able to create an object which is of no use to me. It should display
a database error, right?

Regards,
rAinDeEr

Jun 22 '06 #3

P: n/a
"rAinDeEr" <ta**********@gmail.com> wrote in message
news:11**********************@c74g2000cwc.googlegr oups.com...

Hi Mark,
That doesnt answer my question. I dont have any table/view but still I
am able to create an object which is of no use to me. It should display
a database error, right?

Regards,
rAinDeEr


No, it does not give a database error. You can create the alias before the
table, or you can drop the table and the alias still exists.
Jun 22 '06 #4

P: n/a
Mark A wrote:
"rAinDeEr" <ta**********@gmail.com> wrote in message
news:11**********************@c74g2000cwc.googlegr oups.com...
Hi Mark,
That doesnt answer my question. I dont have any table/view but still I
am able to create an object which is of no use to me. It should display
a database error, right?

Regards,
rAinDeEr


No, it does not give a database error. You can create the alias before the
table, or you can drop the table and the alias still exists.

The "technical" reason why this works is that teh ALIAS contains no
information that requires the existence of the underlying objects.
It's just a forward pointer.
By contrast a view needs to be able to derive the column names and
column types, so it requires teh underlying table to exists.
Note that You can't use the alias in e.g. a view unless the underlying
object exists.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Jun 22 '06 #5

P: n/a

Serge Rielau wrote:
Mark A wrote:
"rAinDeEr" <ta**********@gmail.com> wrote in message
news:11**********************@c74g2000cwc.googlegr oups.com...
Hi Mark,
That doesnt answer my question. I dont have any table/view but still I
am able to create an object which is of no use to me. It should display
a database error, right?

Regards,
rAinDeEr


No, it does not give a database error. You can create the alias before the
table, or you can drop the table and the alias still exists.

The "technical" reason why this works is that teh ALIAS contains no
information that requires the existence of the underlying objects.
It's just a forward pointer.
By contrast a view needs to be able to derive the column names and
column types, so it requires teh underlying table to exists.
Note that You can't use the alias in e.g. a view unless the underlying
object exists.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/


Hi,

Agree its a forward pointer. But if i Dont have any thg to point why
does it create a pointer....

<<Sigh>>...May be there is lot of Technical Design involved..lot of
advantages that I dont see...will come back 2morrow and think about
it...

Thanks Mark , Serge

Regards,
rAinDeEr

Jun 22 '06 #6

P: n/a
Ian
rAinDeEr wrote:

Agree its a forward pointer. But if i Dont have any thg to point why
does it create a pointer....

<<Sigh>>...May be there is lot of Technical Design involved..lot of
advantages that I dont see...will come back 2morrow and think about
it...


Why is this a problem?

Realize that aliases are "special" objects. If you try and do a select
from an alias that points to nothing, you will get SQL0204N (table does
not exist), but the error message refers to the table referenced by the
alias, not the alias.

Also, if you say, "drop table my.alias", would you expect DB2 to drop
the alias or the table?

Jun 22 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.