what is 'force view'?

Answer Posted / m arun kumar

FORCE
The FORCE option of the CREATE VIEW statement can be used
to create the object even if one of the underlying objects
(i.e. referenced within the view) do not exist.

This can be useful if the views are created before the
underlying objects in creation scripts etc.
/* Try to create a view against a table which does not
exist */

SQL> CREATE OR REPLACE VIEW test_view
2 AS
3 SELECT * FROM non_existent_table;
SELECT * FROM non_existent_table
*
ERROR at line 3:
ORA-00942: table or view does not exist

/* Hence, the view does not exists */

SQL> SELECT * FROM test_view;
SELECT * FROM test_view
*
ERROR at line 1:
ORA-00942: table or view does not exist

/* Specifying FORCE creates the view object (albeit with
errors) */

SQL> CREATE OR REPLACE FORCE VIEW test_view
2 AS
3 SELECT * FROM non_existent_table;

Warning: View created with compilation errors.

/* Trying to SELECT from the view implies it's been created
*/

SQL> SELECT * FROM test_view;
SELECT * FROM test_view
*
ERROR at line 1:
ORA-04063: view "ORAUSER.TEST_VIEW" has errors

/* Creating the missing object then allows us to select
from it */

SQL> CREATE TABLE non_existent_table
2 (
3 a VARCHAR2(10)
4 );

Table created.

SQL> SELECT * FROM test_view;

no rows selected

Is This Answer Correct ?    19 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between a primary key and a unique key?

556


How can we debug in PL/SQL?

655


How many developers work on postgresql?

561


i have a column which may contain this kind of value: 123*67_80,12*8889_5,34*8_874 ,12*7_7 (can contain space before a comma, and this string length can be anything) now i want to split this value into two column like: column1: 123*67,12*8889,34*8,12*7 column2: 80,5,874,7 use function for this

1063


Explain sql data types?

627






What is output spooling in sql*plus?

551


Is trigger a stored procedure?

504


who introduced sql?

568


what does it mean to have quoted_identifier on? What are the implications of having it off? : Sql dba

526


Which one is better subquery or joins?

554


Explain the purpose of %type and %rowtype data types?

503


How to sort the rows in sql.

600


explain commit and rollback in mysql : sql dba

545


How do I run a program in pl sql?

499


What is gpt format?

505