ORA-20000: Insufficient privileges to analyze an object in Schema
今天收到一些foglight的報警,說一些自動執行的dbms_stats.gather_schema_stats報這些錯:
Fri Nov 23 13:47:29 2007
Errors in file c:oracleadminrcatudumprcat_j001_3928.trc:
ORA-12012: error on auto execute of job 22
ORA-20000: Insufficient privileges to analyze an object in Schema
ORA-06512: at "SYS.DBMS_STATS", line 9635
ORA-06512: at "SYS.DBMS_STATS", line 9800
ORA-06512: at "SYS.DBMS_STATS", line 9854
ORA-06512: at "SYS.DBMS_STATS", line 9831
ORA-06512: at "SYSTEM.DBA_TABLE_ANALYZE", line 12
ORA-06512: at line 1
到metalink查了一下,是一個bug,實際上很簡單,如果用sys使用者是沒有問題的,如果用的是system使用者,則需要用sys使用者給system使用者授權:
sql>grant select any table ,anylyze any to system;
這樣就可以了。
[@more@]Problem statement:
ORA-20000 INSUFFICIENT PRIVILEGES RUNNING JOB W/DBMS_STATS.GATHER_SCHEMA
*** 01/27/04 01:29 pm ***
TAR:
----
3572308.996
.
PROBLEM:
--------
If a job is submitted by the SYSTEM user and that job calls
DBMS_STATS.GATHER_SCHEMA_STATS ... and the schema in question contains a table
with a single index (PK) ... The job will fail with
.
ORA-12012: error on auto execute of job 100
ORA-20000: Insufficient privileges to analyze an object in Schema
ORA-06512: at "SYS.DBMS_STATS", line 9876
ORA-06512: at "SYS.DBMS_STATS", line 10041
ORA-06512: at "SYS.DBMS_STATS", line 10095
ORA-06512: at "SYS.DBMS_STATS", line 10072
ORA-06512: at line 1
.
If the DBMS_STATS.GATHER_SCHEMA_STATS is run from the prompt as SYSTEM ... it
succeeds
.
If the job is run as the owner of the table/pk index ... it succeeds
.
If the job run as SYS it succeeds
.
DIAGNOSTIC ANALYSIS:
--------------------
See testcase
.
WORKAROUND:
-----------
Execute the job as either SYS or the user whos schema is to be analyzed
.
RELATED BUGS:
-------------
Bug.2738070/3165470 ORA-20000 ON DBMS_STATS.EXPORT_TABLE_STATS WHEN OTHER
SCHEMA HAS INDEX ON TABLE
.
REPRODUCIBILITY:
----------------
100%
.
.
=========
TESTCASE:
=========
.
Location : rmtdcsol4/refresh/REF920U6 ... /testcases/kbcook
.
sqlplus "/ as sysdba"
.
CREATE USER MSHASHIDHAR IDENTIFIED BY "hello123";
.
GRANT "RESOURCE" TO MSHASHIDHAR;
.
ALTER USER MSHASHIDHAR DEFAULT ROLE "RESOURCE";
.
GRANT ALTER SESSION TO MSHASHIDHAR;
.
GRANT CREATE PUBLIC SYNONYM TO MSHASHIDHAR;
.
GRANT CREATE SESSION TO MSHASHIDHAR;
.
GRANT UNLIMITED TABLESPACE TO MSHASHIDHAR;
.
EXIT
.
imp system/manager file=da_constraint.dmp fromuser=www_owner
touser=mshashidhar
.
sqlplus system/manager
.
--SQL> select object_name, object_type from dba_objects where owner =
'MSHASHIDHAR';
.
--OBJECT_NAME
-------------------------------------------------------------------------------
-
--OBJECT_TYPE
------------------
--DA_CONSTRAINT
--TABLE
.
--DA_CONSTRAINT_PK
--INDEX
.
begin
sys.dbms_job.isubmit(job => 100,
what => 'begin dbms_stats.gather_schema_stats (ownname
=>
''MSHASHIDHAR'',degree => 3,cascade => TRUE);end;',
next_date => to_date('28-01-2004', 'dd-mm-yyyy'),
interval => 'TRUNC(SYSDATE + 2, ''DD'') + 1/24');
commit;
end;
/
.
exec dbms_job.run(100);
.
! tail /refresh/64bit/app/oracle/admin/REF920U6/bdump/alert_REF920U6.log
.
--Current log# 2 seq# 408 mem# 0:
/refresh/64bit/app/oracle/oradata/REF920U6/reg
--Tue Jan 27 10:25:23 2004
--Errors in file
/refresh/64bit/app/oracle/admin/REF920U6/udump/ref920u6_ora_1699:
--ORA-12012: error on auto execute of job 100
--ORA-20000: Insufficient privileges to analyze an object in Schema
--ORA-06512: at "SYS.DBMS_STATS", line 9876
--ORA-06512: at "SYS.DBMS_STATS", line 10041
--ORA-06512: at "SYS.DBMS_STATS", line 10095
--ORA-06512: at "SYS.DBMS_STATS", line 10072
--ORA-06512: at line 1
.
STACK TRACE:
------------
.
SUPPORTING INFORMATION:
-----------------------
.
24 HOUR CONTACT INFORMATION FOR P1 BUGS:
----------------------------------------
.
DIAL-IN INFORMATION:
--------------------
.
IMPACT DATE:
------------
.
*** 01/27/04 01:37 pm *** (CHG: Sta->16)
*** 01/28/04 10:32 am *** (CHG: Asg->NEW OWNER)
*** 01/29/04 02:14 pm *** (CHG: Sta->32)
*** 01/29/04 02:14 pm ***
This looks like expected behavior.
You can grant 'analyze any' to system:
sqlplus "/ as sysdba"
grant analyze any to system;
and then you will not see the error.
.
You may also need to grant 'select any table' to system if you have not
granted select on da_conatraints to system as the table owner:
i.e.
sqlplus "/ as sysdba"
grant select any table to system;
or
grant select on < tablename> to system;
.
The DBMS_STATS.* package "run[s] with invoker rights -- [it does] not run as
the owner (SYS) but rather as the current user." "An invoker-rights procedure
.
executes with all of the invoker's privileges. Roles are enabled unless the
invoker-rights procedure was called directly or indirectly by a definer-rights
.
procedure." (Quotes taken from Concepts Manual.)
.
"When you force a job to run using the procedure DBMS_JOB.RUN, the job is run
by your user process and with your default privileges only.
Privileges granted to you through roles are unavailable. You must be
explicitly granted the necessary object privileges for all objects
referenced within the job definition." (Quote taken from Database Admin
Guide.)
.
These two quotes explain why when you run:
.
connect system/manager
execute dbms_stats.gather_schema_stats(ownname=> 'MSHASHIDHAR', degree
=>3,cascade => TRUE);
.
you don't get an error, but when you run:
.
connect system/manager
execute dbms_job.run(100);
.
you do get an error.
.
In the first case, the roles granted to system are enabled. The role
imp_full_database, which is granted to the dba role which in turn is granted
to system, includes the 'analyze any' privilege.
.
In the second case, the roles granted to system are unavailable so the
privilege 'analyze any' must be explicitly granted to system.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/14710393/viewspace-1157373/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Difference of Revoke System Privileges and Object PrivilegesObject
- DBMS_UTILITY.ANALYZE_SCHEMA
- ora-01031:insufficient privileges解決方法
- create view receive "ORA-01031: insufficient privileges"View
- Linux oracle ORA-01031: insufficient privilegesLinuxOracle
- Resolution of Schema Object Dependencies (241)Object
- import_schema_stats時報出ORA-20000:Import
- 建立資料庫時“Insufficient privileges”的解決方法DK資料庫
- ORA-01031: insufficient privileges的解決方法
- ORA-0131:Insufficient privileges.(DEBUG CONNECT SESSION)Session
- ORA-01031: insufficient privileges錯誤解決方法
- oracle rac dg庫報錯ORA-01031: insufficient privilegesOracle
- linux as 2.1 ORA-01031: insufficient privileges 解決方法Linux
- 在AIX 平臺下遇到ORA-01031: insufficient privilegesAI
- RMAN system 遠端連線 ORA-01031: insufficient privileges
- 分析物件DBMS_UTILITY.ANALYZE_SCHEMA(8i以前版本)物件
- Oracle遠端登入報錯:ora-01031:insufficient privilegesOracle
- SYS遠端連線出錯ORA-01031:Insufficient privileges
- ORA-01031: insufficient privileges重新配置sys登入密碼密碼
- sys使用者遠端登入報ORA-01031 insufficient privileges
- SYS使用者登入Oracle報錯ORA-01031: insufficient privilegesOracle
- sqlplus / as sysdba報錯ORA-01031: insufficient privileges的原因分析SQL
- conn / as sysdba 出現ORA-01031: insufficient privileges 解決辦法
- ORA-01031: 資料庫恢復時的insufficient privileges錯誤QS資料庫
- 儲存過程編譯報錯:PL/SQL:ORA-01031:insufficient privileges儲存過程編譯SQL
- sys使用者執行 grant授權提示ORA-01031: insufficient privileges
- oracle 10g linux 遠端登入 ORA-01031: insufficient privilegesOracle 10gLinux
- [20240826]奇怪ORA-01031 insufficient privileges報錯.txt
- 同義詞The schema object cannot be contained in a package.ObjectAIPackage
- 11gR2 Restart Database SRVCTL啟動DB報ORA-01031: insufficient privilegesRESTDatabase
- sqlplus "/ as sysdba" 連不上,報ora-01031:insufficient privileges解決方法SQL
- Listings of System and Object Privileges--系統和物件許可權列表Object物件
- Oracle的SYS使用者登入報許可權不足(ORA-01031: insufficient privileges)Oracle
- SQL> conn sys/sys@vm_sigle as sysdba; 報ORA-01031: insufficient privileges錯誤SQL
- Oracle 軟體克隆後sysdba登入提示沒有許可權ora-01031: insufficient privilegesOracle
- linux環境下sqlplus sys/sys@ORCL as sysdba報錯 ORA-01031: insufficient privilegesLinuxSQL
- 使用SYS使用者遠端登陸報許可權不足的解決:ORA-01031: insufficient privileges
- chained rows analyzeAI