what is 'force view'?

Answers were Sorted based on User's Feedback



what is 'force view'?..

Answer / 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

what is 'force view'?..

Answer / suresh

the view can be created without base table then the view is
called force view. the view must be crated with force option.

Is This Answer Correct ?    16 Yes 0 No

what is 'force view'?..

Answer / dinesh kumar

Force View creates view even if the base table is not
available.

Is This Answer Correct ?    4 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

Where are my tempfiles, I don't see them in v$datafile or dba_data_file?

0 Answers  


Write an sql query to select all records from the table?

0 Answers  


source destination distance chennai bangalore 500 bangalore chennai 500 hyd delhi 1000 delhi hyd 1000 bangalore hyd 800 Here chennai to bangalore and bangalore to chennai is same distance. and hyd and delhi also same criteria. Based on the distance i want to display only one row using sql query?

4 Answers   JPMorgan Chase,


Does view contain data?

0 Answers  


Why do we use procedures in sql?

0 Answers  






using subquery how can i calculate working days in a month?

3 Answers   Spice Telecom,


How to move files from one directory to another in pl sql?

0 Answers  


What is nosql example?

0 Answers  


What is difference between a Cursor declared in a procedure and Cursor declared in a package specification ?

2 Answers   JDA,


Why we use pl sql?

0 Answers  


What is difference between primary and secondary key?

0 Answers  


Explain the working of foreign key?

0 Answers  


Categories