RE: table aliases save time when parsing??

2001-07-10 Thread Gillies, Garry




Consider
 
SQL> select deptno from emp, 
dept; select deptno from emp, 
dept    * ERROR at line 1: 
ORA-00918: column ambiguously defined
 
The 
column deptno would be checked against one of the tables and would be found 
to
be 
valid, but the checking cannot stop there. The other table must also be checked 
for
a 
possible conflict ( which there is in this case ).
 
 
select 
d.deptno from emp e, dept d;
 
Does 
not just resolve the conflict, it removes the need for any checking on 
emp.
 
Any 
column which is not aliased will have to be checked against ALL tables 
mentioned,
so 
aliasing can save quite a lot of time.
 
Regards
 
Garry 
 -Original 
Message-From: novicedba 
[mailto:[EMAIL PROTECTED]]Sent: 10 July 2001 
12:11

  Hi,
    was reading 
  CorrelatedSubqueries.pdf from 
  oriole corp.
  In fact it's good programming 
  practice to use aliases in every situation where more than one table is 
  referred to in a statement, since it saves time when parsing.
   
  Can some one please explain how it 
  helps?
All internet traffic to this site is 
automatically scanned for viruses 
and vandals.




Re: table aliases save time when parsing??

2001-07-10 Thread Igor Neyman



Well, it's not aliases themselves, but the practice of using 
aliases as prefixes, when referring to columns:
 
SELECT t1.col1, t1.col2, t2.col1
FROM table1 t1, table2 t2
WHERE t1.col2 = t2.col2
 
that's what saves time when parsing: this way you tell the 
parser which table column list to look for, otherwise (when no 
prefixes used) it has to search through all tables column lists for 
particular column definition (and also to make sure, that this column name 
is unique in all column lists - if not you'll be getting an error, if not using 
prefixes).
 
But, you can get the same result (save time on parsing), when 
using table names as prefixes:
 

SELECT table1.col1, table1.col2, table2.col1
FROM table1, table2
WHERE table1.col2 = table2.col2
 
It's just that aliases are usually short (while table names could be long), 
and it's easier to read the code.
 
List, please correct me, if I'm wrong.
 
Igor Neyman, OCP DBAPerceptron, Inc.(734)414-4627[EMAIL PROTECTED]  


  - Original Message - 
  From: 
  novicedba 
  To: Multiple recipients of list ORACLE-L 
  
  Sent: Tuesday, July 10, 2001 7:10 
AM
  Subject: table aliases save time when 
  parsing??
  
  Hi,
    was reading 
  CorrelatedSubqueries.pdf from 
  oriole corp.
  In fact it's good programming 
  practice to use aliases in every situation where more than one table is 
  referred to in a statement, since it saves time when parsing.
   
  Can some one please explain how it 
  helps?
   
  cozI am anoviceOracle Certifiable 
  DBBS