What is the function of 'force' in view?

Showing Answers 1 - 17 of 17 Answers

arvind

  • Mar 17th, 2006
 

Force is used to create the view name even if that name was already exist in the schema,In breif it acts like a create or replace of Package/Procedure/Functions.

  Was this answer useful?  Yes

Ashish

  • Mar 17th, 2006
 

It will create the view even if there are errors in the SQL statement.

  Was this answer useful?  Yes

vishnu

  • Mar 20th, 2006
 

Hi,

As per Oracle Documentation a view can be created without existence of Base table and not to replace a view. As two views can not be created with same name.

I have tried to create view with option FORCE without a table but recieved an exception "ORA-00942: table or view does not exist"

Can any one pls suggest hot to use this FORCE option, pls mail me at vishnu.sriramula@gmail.com.

Thanks in advance

vishnu

  Was this answer useful?  Yes

pawan ahuja

  • Mar 21st, 2006
 

 this the 100% correct.

Hi,

A view can be created without existence of Base table and not to replace a view. As two views can not be created with same name.

/*Actually one more thing important is that u can create view without the defination of table With force option. it will be create but the status of the view will be invalid*/

 Regards

Pawan Ahuja

919342927335

  Was this answer useful?  Yes

tarun

  • Apr 27th, 2006
 

force in view is used to create the view even if there is no existence of the base tables on which the view is created

  Was this answer useful?  Yes

AyanM

  • Jul 11th, 2006
 

its possible to create a view without having the base table and that is force view. While creating the force view it will show an erorr message (due to non existance of the base table) - ignore that. Any select query on this view will return error at this point of time. Create the base table now and try to select from the view. The select query will work now.

  Was this answer useful?  Yes

Shiv Mangal Rahi

  • Jul 21st, 2006
 

Hi All,

Force view is created only when you want to create a view for which base table doesnt exist. As it will only create view but could not be used because it will be in invalid mode.

It will come in valid mode only when you will create respective base table and recompile the view.

For example:

Suppose we try to create a view vw_emp on a non existing table emp.

SQL> Create View vw_emp as Select empid, empname from emp;

This command will give an error ORA-000942.

However if we use the FORCE option, it will create the view.However trying to access the view gives an error,because the table 'emp' doesnt exist. 

SQL> Create FORCE VIEW vw_emp as select empid,empname from emp;

It will give a warning: View created with compilation error.

      

  Was this answer useful?  Yes

Narendra Joshi

  • Jul 27th, 2006
 

When a view is created that refers to a non-existent table or an invalid column of an existing table, or if the owner of the view does not have the required privileges, then the view can still be created and entered into the data dictionary with FORSE option.

  Was this answer useful?  Yes

Rama Krishna

  • Aug 6th, 2006
 

"Force" option used to create a view without existance of Table in the database

Syntax: Create or replace FORCE VIEW as select  * from <non-exist tab name>

Thanks&Regds

Ramki,TCS,Hyd 9989018508

  Was this answer useful?  Yes

accrash

  • Mar 12th, 2010
 

The use of force is to create a view even if the base doesnt exist but if one will create a view using this option it will give you compilation error at the time of creating it .

The only use that I can understand is that suppose we are not sure about the table then also a view can be created but in order to use the view, first base has to created.

Suppose I want to create a view called temp based on the table test (doesnt exist) then the command will be

create force view temp as
  select * from test;

It will create the view but with compilation error.

One can see the status of it as INVALID by querying user_objects , dba_objects depends on the user through which you are connecting

Hope this will help!

  Was this answer useful?  Yes

SujitKr

  • Mar 14th, 2010
 

The Clause "force" implies to create a view without there being base table. The View remains invalid untill the base table named in the creation is created. As soon as the base table becomes live, the View becomes Valid.
eg. create force view s as select ename,sal,deptno from ss;
here table "ss" has not yet been created
so o/p would be view created with compilation errors.
now as soon as the table "ss" is created then the view "s" becomes valid.
Now, you can query the view but, o/p will be no "no rows selected" as the table "ss" yet doesn't contain data.
Insert Data and now, view will return data.

Sujit

  Was this answer useful?  Yes

Ganesh D. Dalvi

  • Oct 20th, 2011
 

hey vishnu,
we create the FORCE view on the table which is not exist in our database. it will show the error but actually that view is created with your specify name.
Just try it

  Was this answer useful?  Yes

murali

  • Apr 18th, 2013
 

views are created by without base tables is called force views...

  Was this answer useful?  Yes

gopalakrshna

  • Jul 28th, 2015
 

Force view can be created without containing any table in schema

  Was this answer useful?  Yes

Kelly Bailey

  • Feb 28th, 2018
 

For people like myself, who might not immediately recognize why we might want to use Force:

1) Not all logins have the same privileges. If the code is developed under one login, but the view is created by a different user, or under a different login, or in a different schema, then the needed permissions might not all be in place when the view is created. Force allows the view to be created even if there is a table, view, or function that the schema owner doesn't have access to.

2) You develop multiple objects - perhaps some new tables, views, and a function or two - in a non-production environment. Now you are ready to deploy them into production. Force makes this easier, because you don't have to create everything in a certain sequence. Without Force, you would have to figure out the order to deploy each object based on the upstream and downstream dependencies.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.