Re: Column aliasing

From: Stephane Faroult <sfaroult_at_roughsea.com>
Date: Fri, 20 Jul 2012 16:17:32 +0200
Message-ID: <5009687C.8020103_at_roughsea.com>



On 07/20/2012 02:16 PM, rjamya wrote:
> Hi all,
>
> Is there a way to detect column aliasing (or double-aliasing) in view
> scripts other than manual look over? Here is a classic example of
> double aliasing that i see in some of the code
>
> create view view1 (col1, col2, col3) as select column_1 as a, column_2
> as b, column_3 as c from blah blah;
>
> so in select column_1 is aliased as "A", which is exposed in the view
> as "COL1". I know this is no harm, but sure confuses the heck when you
> read something when your view had 40+ columns and your view definition
> has UNION ALL etc.
>
> Just curious (version 11.2)
> Raj
> --
> http://www.freelists.org/webpage/oracle-l
>
>
>

Raj,

    Col1, Col2 and so on are in dba_tab_columns (or sys.col$). I think that by retrieving the view text from dba_views or sys.view$ and using that good old dbms_sql package to parse it you can get the description of the columns and compare to what you have in the first one. I haven't tried it but it can probably be done.

HTH

-- 
Stephane Faroult
RoughSea Ltd <http://www.roughsea.com>
Konagora <http://www.konagora.com>
RoughSea Channel on Youtube <http://www.youtube.com/user/roughsealtd>


--
http://www.freelists.org/webpage/oracle-l
Received on Fri Jul 20 2012 - 09:17:32 CDT

Original text of this message