<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>惜分飞 &#187; ORA-01031</title>
	<atom:link href="https://www.xifenfei.com/tag/ora-01031/feed" rel="self" type="application/rss+xml" />
	<link>https://www.xifenfei.com</link>
	<description>提供7*24专业数据库(Oracle,SQL Server,MySQL,PostgreSQL等)恢复和技术支持@Tel:17813235971</description>
	<lastBuildDate>Wed, 04 Nov 2026 15:33:30 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>创建视图提示ORA-01031</title>
		<link>https://www.xifenfei.com/2011/12/%e5%88%9b%e5%bb%ba%e8%a7%86%e5%9b%be%e6%8f%90%e7%a4%baora-01031.html</link>
		<comments>https://www.xifenfei.com/2011/12/%e5%88%9b%e5%bb%ba%e8%a7%86%e5%9b%be%e6%8f%90%e7%a4%baora-01031.html#comments</comments>
		<pubDate>Fri, 09 Dec 2011 08:51:09 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[ORA-xxxxx]]></category>
		<category><![CDATA[ORA-01031]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=2099</guid>
		<description><![CDATA[ORA-01031 <a href="https://www.xifenfei.com/2011/12/%e5%88%9b%e5%bb%ba%e8%a7%86%e5%9b%be%e6%8f%90%e7%a4%baora-01031.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="xifenfeicopyright">
<p>联系：<a href="https://www.xifenfei.com/about_xifenfei" target="_blank">手机/微信(+86 17813235971)   QQ(107644445)</a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&#038;uin=107644445&#038;site=qq&#038;menu=yes"><img src="https://www.xifenfei.com/wp-content/themes/img/site_qq.jpg" alt="QQ咨询惜分飞" title="QQ咨询惜分飞"/></a></p>
<p>标题：<a href="https://www.xifenfei.com/2011/12/%e5%88%9b%e5%bb%ba%e8%a7%86%e5%9b%be%e6%8f%90%e7%a4%baora-01031.html" target="_blank">创建视图提示ORA-01031</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p><strong>1、重现问题</strong></p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE    11.2.0.3.0      Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production

SQL&gt; select table_name from user_tables where table_name in('X_T','DEPT');

TABLE_NAME
------------------------------
X_T

SQL&gt; create view  v_xff1
  2  as 
  3  select * from X_T;

View created.


SQL&gt; create view  V_XFF AS
  2  SELECT * FROM SCOTT.DEPT;
SELECT * FROM SCOTT.DEPT
                    *
ERROR at line 2:
ORA-01031: insufficient privileges


SQL&gt; SELECT COUNT(*) FROM SCOTT.DEPT;

  COUNT(*)
----------
         4
</pre>
<p>通过上面的试验证明：<br />
1）在同一个schema下，有查询权限，就可以创建视图<br />
2）在不同schema下，即使有了查询权限，创建视图，还是会提示ORA-01031<br />
<br />
<strong>2、查看相关权限情况</strong></p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select * from SESSION_PRIVS where 
  2  PRIVILEGE in('SELECT ANY TABLE','CREATE ANY VIEW','CREATE VIEW');

PRIVILEGE
----------------------------------------
SELECT ANY TABLE
CREATE VIEW
CREATE ANY VIEW

SQL&gt; SELECT * FROM SESSION_PRIVS WHERE PRIVILEGE NOT IN(
  2  SELECT PRIVILEGE
  3    FROM ROLE_SYS_PRIVS
  4   WHERE ROLE IN(SELECT * FROM SESSION_ROLES));

no rows selected
</pre>
<p>通过上面权限查询得出：用户所具有的select 其他用户表的权限是用过role授权<br />
<br />
<strong>3、单独授于select权限</strong></p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; conn / as sysdba
Connected.
SQL&gt; grant select on SCOTT.DEPT to xff;

Grant succeeded.

SQL&gt; conn xff/xifenfei
Connected.
SQL&gt; create view  V_XFF AS
  2  SELECT * FROM SCOTT.DEPT;

View created.

SQL&gt; select view_name from user_views;

VIEW_NAME
------------------------------
V_XFF
V_XFF1
</pre>
<p><strong>4、产生问题原因</strong><br />
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<br />
<a href='//www.xifenfei.com/wp-content/uploads/2011/12/271587.1.pdf'>ORA-1031 While Creating A View On A Table On Which The Select Privilege Is Granted Via A Role </a></p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/08/ora-01031-insufficient-privileges.html" rel="bookmark" class="crp_title">ORA-01031: insufficient privileges</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/oracle%e5%b8%b8%e7%94%a8%e7%94%a8%e6%88%b7%e6%9d%83%e9%99%90%e8%a7%86%e5%9b%be.html" rel="bookmark" class="crp_title">Oracle常用用户权限视图</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/08/%e7%89%a9%e5%8c%96%e8%a7%86%e5%9b%beon-prebuilt-table.html" rel="bookmark" class="crp_title">物化视图on prebuilt table</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/12/%e5%9b%9e%e6%94%b6dba%e4%b8%adalter-system%e5%a4%84%e7%90%86%e6%96%b9%e6%b3%95.html" rel="bookmark" class="crp_title">回收dba中alter system处理方法</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/08/%e5%88%a9%e7%94%a8%e7%89%a9%e5%8c%96%e8%a7%86%e5%9b%be%e5%88%b7%e6%95%b0%e6%8d%ae.html" rel="bookmark" class="crp_title">利用物化视图刷数据</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/03/grant-dml-to-public-authorization-expires.html" rel="bookmark" class="crp_title">表dml操作权限授权给public,导致只读用户失效</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2024/07/sqlplus-errordetails.html" rel="bookmark" class="crp_title">Oracle23ai新特性&#8212;sqlplus errordetails功能</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/03/%e6%8e%88%e6%9d%83%e7%94%a8%e6%88%b7%e8%ae%bf%e9%97%ae%e6%95%b0%e6%8d%ae%e5%ad%97%e5%85%b8%e4%b8%89%e7%a7%8d%e6%96%b9%e5%bc%8f.html" rel="bookmark" class="crp_title">授权用户访问数据字典三种方式</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2015/05/%e9%80%9a%e8%bf%87with%e5%ae%9e%e7%8e%b0%e5%af%b9%e8%a1%a8%e9%9d%9e%e6%b3%95dml%e6%93%8d%e4%bd%9c-%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88.html" rel="bookmark" class="crp_title">通过with实现对表非法dml操作&#8212;解决方案_with_subquery=materialize或者psu(2014.07以后)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2024/07/grant-select-any-table-on-schema.html" rel="bookmark" class="crp_title">Oracle23ai新特性&#8212;SCHEMA级授权( grant select any table on schema)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/06/deferred_segment_creation-%e5%8f%82%e6%95%b0%e7%9b%b8%e5%85%b3%e8%af%b4%e6%98%8e.html" rel="bookmark" class="crp_title">DEFERRED_SEGMENT_CREATION 参数相关说明</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/04/update-user-ora-01031.html" rel="bookmark" class="crp_title">update user$报ORA-01031错误</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2011/12/%e5%88%9b%e5%bb%ba%e8%a7%86%e5%9b%be%e6%8f%90%e7%a4%baora-01031.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>win平台登录sqlplus报ora-01031错误解决</title>
		<link>https://www.xifenfei.com/2011/11/win%e5%b9%b3%e5%8f%b0%e7%99%bb%e5%bd%95sqlplus%e6%8a%a5ora-o1031%e9%94%99%e8%af%af%e8%a7%a3%e5%86%b3.html</link>
		<comments>https://www.xifenfei.com/2011/11/win%e5%b9%b3%e5%8f%b0%e7%99%bb%e5%bd%95sqlplus%e6%8a%a5ora-o1031%e9%94%99%e8%af%af%e8%a7%a3%e5%86%b3.html#comments</comments>
		<pubDate>Sun, 06 Nov 2011 02:45:37 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[ORA-xxxxx]]></category>
		<category><![CDATA[ORA-01031]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=1774</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2011/11/win%e5%b9%b3%e5%8f%b0%e7%99%bb%e5%bd%95sqlplus%e6%8a%a5ora-o1031%e9%94%99%e8%af%af%e8%a7%a3%e5%86%b3.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="xifenfeicopyright">
<p>联系：<a href="https://www.xifenfei.com/about_xifenfei" target="_blank">手机/微信(+86 17813235971)   QQ(107644445)</a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&#038;uin=107644445&#038;site=qq&#038;menu=yes"><img src="https://www.xifenfei.com/wp-content/themes/img/site_qq.jpg" alt="QQ咨询惜分飞" title="QQ咨询惜分飞"/></a></p>
<p>标题：<a href="https://www.xifenfei.com/2011/11/win%e5%b9%b3%e5%8f%b0%e7%99%bb%e5%bd%95sqlplus%e6%8a%a5ora-o1031%e9%94%99%e8%af%af%e8%a7%a3%e5%86%b3.html" target="_blank">win平台登录sqlplus报ora-01031错误解决</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>今天一朋友告诉我，他的win平台的oracle不能在本地使用sqlplus / as sysdba登录数据库，提示ora-01031的错误，他说是administrator用户，应该不会出现权限不足的情况。我的登录上去一看，果真是这样的情况：<br />
<img alt="" src="wp-content/uploads/ckfinder/images/no_priv4.jpg" /></p>
<div>
	<span style="font-size:10px;">01031, 00000, &quot;insufficient privileges&quot;</span></div>
<div>
	<span style="font-size:10px;">// *Cause: An attempt was made to change the current username or password</span></div>
<div>
	<span style="font-size:10px;">// &nbsp; &nbsp; &nbsp; &nbsp; without the appropriate privilege. This error also occurs if</span></div>
<div>
	<span style="font-size:10px;">// &nbsp; &nbsp; &nbsp; &nbsp; attempting to install a database without the necessary operating</span></div>
<div>
	<span style="font-size:10px;">// &nbsp; &nbsp; &nbsp; &nbsp; system privileges.</span></div>
<div>
	<span style="font-size:10px;">// &nbsp; &nbsp; &nbsp; &nbsp; When Trusted Oracle is configure in DBMS MAC, this error may occur</span></div>
<div>
	<span style="font-size:10px;">// &nbsp; &nbsp; &nbsp; &nbsp; if the user was granted the necessary privilege at a higher label</span></div>
<div>
	<span style="font-size:10px;">// &nbsp; &nbsp; &nbsp; &nbsp; than the current login.</span></div>
<div>
	<span style="font-size:10px;">// *Action: Ask the database administrator to perform the operation or grant</span></div>
<div>
	<span style="font-size:10px;">// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;the required privileges.</span></div>
<div>
	<span style="font-size:10px;">// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;For Trusted Oracle users getting this error although granted the</span></div>
<div>
	<span style="font-size:10px;">// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;the appropriate privilege at a higher label, ask the database</span></div>
<div>
	<span style="font-size:10px;">// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;administrator to regrant the privilege at the appropriate label.</span><br />
	根据这个错误提示，我的第一反应就是当前的用户不属于ora_dba用户组，通过计算机管理&#8211;&gt;本地用户和组&#8211;&gt;administrator用户属性&#8211;&gt;隶属于中只有一个administrators，果然没有ora_dba组<br />
	<img alt="" src="wp-content/uploads/ckfinder/images/no_priv1.jpg" /><br />
	接下来的事情，就是添加ora_dba组到administrator用户中<br />
	点击刚刚隶属于下面的添加&#8211;&gt;高级&#8211;&gt;立即查找&#8211;选择ora_dba&#8211;点击确定&#8211;&gt;再点击选择组中的确定&#8211;&gt;点击用户属性的确定<br />
	<img alt="" src="wp-content/uploads/ckfinder/images/no_priv2.jpg" /><br />
	<img alt="" src="wp-content/uploads/ckfinder/images/no_priv3.jpg" /><br />
	添加把ora_dba添加到administrator用户所属组中，再尝试登录<br />
	<img alt="" src="wp-content/uploads/ckfinder/images/no_priv5.jpg" /><br />
	ok，登录成功了，看来在win系统中，要想使用sqlplus / as sysdba 登录数据库，必须要隶属于ora_dba组，就算administrators组也不能越俎代庖。</div>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/linux%e4%b9%8bpmap%e5%91%bd%e4%bb%a4.html" rel="bookmark" class="crp_title">Linux之pmap命令</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/1749.html" rel="bookmark" class="crp_title">Oracle 10.2.0.x升级到11.2.0.3</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/ora-00845-memory_target-not-supported-on-this-system-2.html" rel="bookmark" class="crp_title">ORA-00845: MEMORY_TARGET not supported on this system</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/%e5%90%8c%e5%8f%b0%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%a4%9a%e7%89%88%e6%9c%ac%e6%95%b0%e6%8d%ae%e5%ba%93%e7%9b%91%e5%90%ac%e9%85%8d%e7%bd%ae.html" rel="bookmark" class="crp_title">同台服务器多版本数据库监听配置</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/%e5%9d%97%e4%bf%ae%e6%94%b9%e8%b7%9f%e8%b8%aa%e7%89%b9%e6%80%a7block-change-tracking.html" rel="bookmark" class="crp_title">块修改跟踪特性(Block Change Tracking)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/10/sp2-1503-sp2-0152-%e9%94%99%e8%af%af%e8%a7%a3%e5%86%b3.html" rel="bookmark" class="crp_title">SP2-1503   SP2-0152  错误解决</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/10-2-0-x%e5%8d%87%e7%ba%a7%e5%88%b010-2-0-5-5.html" rel="bookmark" class="crp_title">10.2.0.x升级到10.2.0.5.5</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/redhat-6-1%e5%ae%89%e8%a3%85oracle-11-2-0-3.html" rel="bookmark" class="crp_title">RedHat 6.1安装Oracle 11.2.0.3</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/disableenable-oracle-database-vault.html" rel="bookmark" class="crp_title">Disable/Enable Oracle Database Vault</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/04/oracle-awr%e4%bd%bf%e7%94%a8.html" rel="bookmark" class="crp_title">ORACLE AWR使用</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/10/oracle%e4%b8%adconnect-by-start-with-%e7%9a%84%e4%bd%bf%e7%94%a8.html" rel="bookmark" class="crp_title">Oracle中connect by…start with…的使用</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2019/06/your_last_chance-recovery.html" rel="bookmark" class="crp_title">.YOUR_LAST_CHANCE加密数据库恢复</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2011/11/win%e5%b9%b3%e5%8f%b0%e7%99%bb%e5%bd%95sqlplus%e6%8a%a5ora-o1031%e9%94%99%e8%af%af%e8%a7%a3%e5%86%b3.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
