问题
We created a view for handling complex SQL, But when creating a view using FORCE option. e.g:
create or replace FORCE view testview as
select 1
from dual;
FORCE
is removed when viewing the view later
create or replace view testview as
select 1
from dual;
Specify FORCE if you want to create the view regardless of whether the base tables of the view or the referenced object types exist or the owner of the schema containing the view has privileges on them. These conditions must be true before any SELECT, INSERT, UPDATE, or DELETE statements can be issued against the view.
If the view definition contains any constraints, CREATE VIEW ... FORCE will fail if the base table does not exist or the referenced object type does not exist. CREATE VIEW ... FORCE will also fail if the view definition names a constraint that does not exist.
Is using FORCE
option is only in execution time with no runtime effects? and is it only used for force overriding the previous view (even on error)?
回答1:
Is using FORCE option is only in execution time with no runtime effects?
Yes. If the view statement is invalid - say there's a typo and the table name in the FROM clause is misspelled - normally Oracle wouldn't create the view. By using the FORCE keyword the view is created but with an 'INVALID'
status. This can be useful in certain situations, e.g. we have a build tool which stops running if a statement fails but we would prefer the whole build to finish then sort out any inconsistencies.
is it only used for force overriding the previous view
No. We can choose to use FORCE even if the view doesn't exist prior to this moment. The usage is slightly different from the use of FORCE when we ALTER a TYPE with dependencies. We can always create or replace a view.
来源:https://stackoverflow.com/questions/53912601/oracle-force-view-option-isnt-shown-on-view-after-executed