無法在 Oracle 表上創建簡單視圖 (Unable to create a simple view on Oracle table)


問題描述

無法在 Oracle 表上創建簡單視圖 (Unable to create a simple view on Oracle table)

An external DB admin guy exported a production database and imported it into test environment.  We are using Oracle 9.2.  Majority of imported database objects (tables, views, idexes, packages,...) works fine, but we have problems with three specific tables: we can do SELECT,UPDATE, DELETE on those tables, but we can not create views on this tables.

In other words, the folowing works:

 create or replace view v_test_view as select 1 x from dual; // we can create views
 create or replace view v_test_view  as select 1 x from someTable;
 select * from problematicTable; // we can select data from problematic table

But this does NOT work:

 create or replace view v_test_view  as select 1 x from problematicTable;
--> ORA-01031: insufficient privileges

Background info:

  • db admin used import/export utility  to copy the database schema
  • the version of production and test Oracle are not exactly the same (production is 9.2.0.8, test is 9.2.0.7)
  • after the initial import was done, the problematicTable was visible in object catalog (and database development tools), but when trying to SELECT from this table, we got back "invalid identifier". After that, the tables were re-imported and now we are able to SELECT from the, but not to create views on them 

Any ideas?

UPDATE: It looks like the situation is even more strange. When using one oracle session we can SELECT data from this table, in another Oracle session (using the same user to login!), we are getting "ORA-00904: invalid identifier"

UPDATE#2: The export data that was used to import from was sucesfully used to import data to another test environment (lets call it TEST1) which is located on the same instace of Oracle as the problematic one (TEST2). The difference beteween those two environments are that TEST1 uses the same user (schema name) as the production, but TEST2 uses another user (soo the objects were imported into another schema name). The problematicTables do not have any special security properties that are different from the tables that works OK. 

Matra


參考解法

方法 1:

Is the user creating the view granted select on the problematic table via a ROLE? If so, try giving an explicit grant on the table.

From Oracle:

"In order to create a view in a schema, that schema must have the privileges necessary to either select, insert, update, or delete rows from all the tables or views on which the view is based. The view owner must be granted these privileges directly, rather than through a role. The reason is that privileges granted to roles cannot be inherited via objects."

方法 2:

It looks like there was something wrong with the import. So what our DB admin did to fix the problem was:

  • drop the problematic tables
  • reimport the structure of the problematic tables (columns, constraints, indexes)
  • after the structure was re-created he re-imported the data
  • he also played with the CREATE TABLE AS SELECT  to copy the data back and forth

When he was re-creating the table structure he discovered, that the current schema run out of free space (it was not set to auto grow). The strange thing is, that the first import did not complain about insufficient space.  

So in theory is that insufficeint space was the reason for corrupted data dictionary.

(by MatraDCookieMatra)

參考文件

  1. Unable to create a simple view on Oracle table (CC BY-SA 3.0/4.0)

#Security #SQL #oracle #views






相關問題

只允許 oracle db 登錄到特定的應用程序? (Allowing oracle db login only to specific application?)

在桌面應用程序中保存用戶名和密碼 (Saving username & password in desktop app)

如何使用算法 RSA/ECB/PKCS1Padding 通過 JavaScript 解密加密字符串 (How to decrypt through JavaScript of encrypted string using algorithm RSA/ECB/PKCS1Padding)

wcf:將用戶名添加到消息頭是否安全? (wcf: adding username to the message header is this secure?)

沒有 .htaccess 的安全目錄密碼保護 (Secure directory password protection without .htaccess)

無法在 Oracle 表上創建簡單視圖 (Unable to create a simple view on Oracle table)

當請求來自調度程序時,無法寫入 App_Data (Cannot write in App_Data when request is from scheduler)

安全的 PHP 文件上傳 (Secure PHP file uploading)

Grails Spring 安全配置通過 xml (Grails Spring Security Configuration thru xml)

醫療應用的安全要求 (Security Requirements for Medical Applications)

如何保護 Silverlight 應用程序 (How to Secure Silverlight Application)

在使用 azure 流量管理器和 azure 應用程序網關與 WAF 時實現國家級阻止 (Achieve country level blocking while using azure traffic manager and azure application gateway with WAF)







留言討論