Exforsys.com
 
Home Tutorials Oracle 10g
 

Oracle 10g Tutorials - Creating Views, Altering, Dropping and Replacing Views

 

Oracle 10g Tutorials - Creating Views, Altering, Dropping and Replacing Views - Page 3

Page 3 of 3



Replacing View

To replace a view, you must have all the privileges required to drop and create a view. If the definition of a view must change, the view must be replaced; you cannot use an ALTER VIEW statement to change the definition of a view. You can replace views in the following ways:


  • You can drop and re-create the view.

Caution:


When a view is dropped, all grants of corresponding object privileges are revoked from roles and users. After the view is re-created, privileges must be regranted.


  • You can redefine the view with a CREATE VIEW statement that contains the OR REPLACE clause. The OR REPLACE clause replaces the current definition of a view and preserves the current security authorizations. For example, assume that you created the sales_staff view as shown earlier, and, in addition, you granted several object privileges to roles and other users. However, now you need to redefine the sales_staff view to change the department number specified in the WHERE clause. You can replace the current version of the sales_staff view with the following statement:

CREATE OR REPLACE VIEW sales_staff AS
SELECT empno, ename, deptno
FROM emp
WHERE deptno = 30
WITH CHECK OPTION CONSTRAINT sales_staff_cnst;


The image cannot be displayed, because it contains errors.


Figure 16. Creating views with force option and replacing views


Before replacing a view, consider the following effects:


Replacing a view replaces the view definition in the data dictionary. All underlying objects referenced by the view are not affected.


If a constraint in the CHECK OPTION was previously defined but not included in the new view definition, the constraint is dropped.


All views and PL/SQL program units dependent on a replaced view become invalid (not usable).




First Page: Oracle 10g Tutorials - Creating Views, Altering, Dropping and Replacing Views


Read Next: Oracle 10g Tutorials- Updating Views



 

 

Comments


Jay said:

  I am trying to create a view with MINUS between two SELECT queries .
Say for example,
CREATE OR REPLACE VIEW DEPT AS
(SELECT DISTINCT emp_num from emp)
MINUS
(SELECT DISTINCT emp_num FROM managers)
/

But an exception is raised saying
SP-0042 - unkown command "MINUS"

Can anyone please let me if MINUS is a valid operation while creating a view?

Thanks in advance,
Jay
February 11, 2009, 1:24 am

Proprietario said:

  CREATE OR REPLACE VIEW DEPT AS
(SELECT DISTINCT emp_num from emp
MINUS
SELECT DISTINCT emp_num FROM managers);
March 25, 2009, 1:19 pm

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape