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
------ Original Message ------
Received: 05:26 PM EDT, 07/15/2020
From: Eriovaldo Andrietta <ecandrietta@xxxxxxxxx>
To: ORACLE-L <oracle-l@xxxxxxxxxxxxx>
Subject: How can view keep columns from dictionary
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