問題描述
我們創(chuàng)建了一個用于處理復(fù)雜 SQL 的視圖,但是在使用 FORCE 選項.例如:
create or replace FORCE view testview as選擇 1從雙重;
FORCE
稍后查看視圖時移除
創(chuàng)建或替換視圖測試視圖為選擇 1從雙重;
<塊引用>
如果您想創(chuàng)建視圖,而不管視圖的基表或引用的對象類型是否存在,或者包含視圖的架構(gòu)的所有者是否對它們具有特權(quán),請指定 FORCE.在對視圖發(fā)出任何 SELECT、INSERT、UPDATE 或 DELETE 語句之前,這些條件必須為真.
如果視圖定義包含任何約束,如果基表不存在或引用的對象類型不存在,CREATE VIEW ... FORCE 將失敗.如果視圖定義命名了一個不存在的約束,CREATE VIEW ... FORCE 也會失敗.
是否僅在執(zhí)行時使用 FORCE
選項而沒有運行時影響?它是否僅用于強制覆蓋先前的視圖(即使出現(xiàn)錯誤)?
是否僅在執(zhí)行時使用 FORCE 選項而沒有運行時影響?
是的.如果視圖語句無效 - 說有一個錯字并且 FROM 子句中的表名拼寫錯誤 - 通常 Oracle 不會創(chuàng)建視圖.通過使用 FORCE 關(guān)鍵字,視圖被創(chuàng)建但具有 'INVALID'
狀態(tài).這在某些情況下很有用,例如我們有一個構(gòu)建工具,它會在語句失敗時停止運行,但我們希望整個構(gòu)建完成,然后找出任何不一致之處.
是否僅用于強制覆蓋之前的視圖
沒有.即使在此之前視圖不存在,我們也可以選擇使用 FORCE.當(dāng)我們使用依賴項 ALTER 一個 TYPE 時,用法與 FORCE 的用法略有不同.我們可以隨時創(chuàng)建或替換視圖.
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)?
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.
這篇關(guān)于Oracle - FORCE 視圖選項在執(zhí)行后未顯示在視圖中的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!