• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What I Achieve by recompiling a view ?

 
Ranch Hand
Posts: 391
1
MySQL Database PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two questions.

First One is
I created a table as

create table pg(id number,name varchar2(30));

then I created a view as

create view pgview as
select id,name
from pg;

then I changed the datatype of column id as

alter table pg
modify id varchar2(10);

Now I queried the view User_objects and it shows the status of pgview as INVALID

then I inserted a row in the table pg and again queried the view User_objects now it shows the status as VALID.

My question is how status changes from INVALID to VALID .


My second quastion is

Suppose I rename a column or drop a column of a table , and that column was included in the view.
Now That view have no meaning ,Even If I try to recompile the view it will say "View altered with compilation errors"
I have to create the view a new altogether.

Now suppose rather than renaming or dropping the column I just change the datatype of the column ,and that column was included in the view.
Now Even If I don`t recompile the view it works ok.

So what I achieve from the statement " alter view view_name compile "

Shukran...

 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Invalid objects in Oracle are automatically recompiled when used. Consider
2) You'll use alter view view_name compile to compile it explicitly, without waiting for it to be used. Typical use would be in schema upgrade scripts, for example - you don't want to wait for the view to be used by an application or user to be compiled, you want to catch any possible problems early.

Edit: I'd suggest reading Oracle's Database Concepts Guide, lots of questions you've asked lately are well covered there.
 
This tiny ad is wafer thin:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic