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
can a stored procedure call itself or recursive stored procedure? How much level sp nesting is possible? : Sql dba
What is sql rowcount?
What are %type and %rowtype for?
How to assign sql query results to pl sql variables?
Can we edit a view in sql?
Does user triggers have entry for trigger with compilation errors?
What are the subsets of sql?
What is a call statement? Explain with an example.
what is msql? : Sql dba
What are the parts of a sql statement?
Cite the differences between execution of triggers and stored procedures?
how are mysql timestamps seen to a user? : Sql dba
Define commit?
How long does it take to learn pl sql?
How can you maintain the integrity of your database on instances where deleting an element in a table result in the deletion of the element(s) within another table?