Re: How can view keep columns from dictionary

From: Stephen Miller <miller_stephen_at_usa.net>
Date: Wed, 15 Jul 2020 19:17:58 -0400
Message-ID: <826ygoXq77360Set.1594855078_at_web12.cms.usa.net>


Always remember that the '*' in a 'SELECT *' is just short hand for the list of currently defined columns in a table or query request.

In this case, when you created the view, ORACLE immediately translated 'SELECT * FROM test' to 'SELECT col1, col2 from test' under the covers.

When you added a new column, the view is still stuck at 'SELECT col1, col2 from test'.

The only way to get the new column into the view is to rebuild the view -- 'CREATE OR REPLACE VIEW vtest AS SELECT * FROM test'

Stephen Miller - email: miller_stephen at usa.net

> Hello,
>
> I have a doubt about this code :
>
> drop table test;
> create table test
> (col1 number,
> col2 number);
>
> create view vtest
> as
> select * from test;
>
> select * from vtest; -- 2 columns
>
> alter table test add col3 number; -- here table has 3 columns
>
> select * from vtest; -- view keeps using 2 columns
>
> Is there a way to retrieve the current columns from table when created view
> as select * from table withou change the view ?
>
> Regards
> Eriovaldo
>

--
http://www.freelists.org/webpage/oracle-l
Received on Thu Jul 16 2020 - 01:17:58 CEST

Original text of this message