<?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; impdp sys授权</title>
	<atom:link href="https://www.xifenfei.com/tag/impdp-sys%e6%8e%88%e6%9d%83/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>Thu, 29 Oct 2026 15:31:46 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>impdp导入数据丢失sys授权问题分析</title>
		<link>https://www.xifenfei.com/2025/01/impdp-missing-sys-priv.html</link>
		<comments>https://www.xifenfei.com/2025/01/impdp-missing-sys-priv.html#comments</comments>
		<pubDate>Mon, 20 Jan 2025 00:17:21 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[逻辑备份/恢复]]></category>
		<category><![CDATA[impdp sys授权]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=11149</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2025/01/impdp-missing-sys-priv.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/2025/01/impdp-missing-sys-priv.html" target="_blank">impdp导入数据丢失sys授权问题分析</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>在使用expdp/impdp迁移的过程中,偶尔会遇到用户中关于sys对象的授权丢失导致不少pl/sql程序无效,通过测试重现sys授权丢失现象<br />
创建用户并进行sys对象授权给该用户</p>
<pre class="brush: sql; title: ; notranslate">
C:\Users\XFF&gt;sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sun Jan 19 12:04:22 2025

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL&gt; create user xff identified by oracle;

User created.

SQL&gt; grant resource,connect to xff;

Grant succeeded.

SQL&gt; grant select on sys.obj$ to xff;

Grant succeeded.

SQL&gt; grant execute on sys.dbms_lock to xff;

Grant succeeded.

SQL&gt; grant select on sys.v_$session to xff;

Grant succeeded.
SQL&gt; exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
</pre>
<p>使用exp导出数据</p>
<pre class="brush: bash; title: ; notranslate">
C:\Users\XFF&gt;expdp &quot;'/ as sysdba'&quot; dumpfile=xff.dmp schemas=xff

Export: Release 11.2.0.4.0 - Production on Sun Jan 19 12:05:35 2025

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting &quot;SYS&quot;.&quot;SYS_EXPORT_SCHEMA_04&quot;:  &quot;/******** AS SYSDBA&quot; dumpfile=xff.dmp schemas=xff
Estimate in progress using BLOCKS method...
Total estimation using BLOCKS method: 0 KB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Master table &quot;SYS&quot;.&quot;SYS_EXPORT_SCHEMA_04&quot; successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_SCHEMA_04 is:
  C:\APP\XFF\ADMIN\ORCL\DPDUMP\XFF.DMP
Job &quot;SYS&quot;.&quot;SYS_EXPORT_SCHEMA_04&quot; successfully completed at Sun Jan 19 12:05:37 2025 elapsed 0 00:00:02
</pre>
<p>使用impdp导入数据</p>
<pre class="brush: bash; title: ; notranslate">
C:\Users\XFF&gt;impdp &quot;'/ as sysdba'&quot; dumpfile=xff.dmp remap_schema=xff:nxff

Import: Release 11.2.0.4.0 - Production on Sun Jan 19 12:06:22 2025

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table &quot;SYS&quot;.&quot;SYS_IMPORT_FULL_01&quot; successfully loaded/unloaded
Starting &quot;SYS&quot;.&quot;SYS_IMPORT_FULL_01&quot;:  &quot;/******** AS SYSDBA&quot; dumpfile=xff.dmp remap_schema=xff:nxff
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Job &quot;SYS&quot;.&quot;SYS_IMPORT_FULL_01&quot; successfully completed at Sun Jan 19 12:06:23 2025 elapsed 0 00:00:00
</pre>
<p>验证用户的权限</p>
<pre class="brush: sql; title: ; notranslate">
C:\Users\XFF&gt;sqlplus xff/oracle

SQL*Plus: Release 11.2.0.4.0 Production on Sun Jan 19 12:09:21 2025

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL&gt; show user;
USER is &quot;XFF&quot;
SQL&gt; select count(1) from v$session;

  COUNT(1)
----------
        26

SQL&gt; select count(1) from sys.obj$;

  COUNT(1)
----------
     90656

SQL&gt; desc sys.dbms_lock
PROCEDURE ALLOCATE_UNIQUE
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOCKNAME                       VARCHAR2                IN
 LOCKHANDLE                     VARCHAR2                OUT
 EXPIRATION_SECS                NUMBER(38)              IN     DEFAULT
FUNCTION CONVERT RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 ID                             NUMBER(38)              IN
 LOCKMODE                       NUMBER(38)              IN
 TIMEOUT                        NUMBER                  IN     DEFAULT
FUNCTION CONVERT RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOCKHANDLE                     VARCHAR2                IN
 LOCKMODE                       NUMBER(38)              IN
 TIMEOUT                        NUMBER                  IN     DEFAULT
FUNCTION RELEASE RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 ID                             NUMBER(38)              IN
FUNCTION RELEASE RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOCKHANDLE                     VARCHAR2                IN
FUNCTION REQUEST RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 ID                             NUMBER(38)              IN
 LOCKMODE                       NUMBER(38)              IN     DEFAULT
 TIMEOUT                        NUMBER(38)              IN     DEFAULT
 RELEASE_ON_COMMIT              BOOLEAN                 IN     DEFAULT
FUNCTION REQUEST RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOCKHANDLE                     VARCHAR2                IN
 LOCKMODE                       NUMBER(38)              IN     DEFAULT
 TIMEOUT                        NUMBER(38)              IN     DEFAULT
 RELEASE_ON_COMMIT              BOOLEAN                 IN     DEFAULT
PROCEDURE SLEEP
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 SECONDS                        NUMBER                  IN

SQL&gt; conn nxff/oracle
Connected.
SQL&gt; desc sys.dbms_lock
ERROR:
ORA-04043: object sys.dbms_lock does not exist


SQL&gt; select count(1) from sys.obj$;
select count(1) from sys.obj$
                         *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL&gt; select count(1) from v$session;
select count(1) from v$session
                     *
ERROR at line 1:
ORA-00942: table or view does not exist
</pre>
<p>确认通过impdp迁移过去的nxff用户没有之前xff用户里面sys授权的对象的访问权限.通过sqlfile查看expdp导出的dmp文件中ddl内容,确认确实没有sys部分的授权<br />
<img src="https://www.xifenfei.com/wp-content/uploads/2025/01/lost-sys-grant.png" alt="lost-sys-grant" width="1048" height="676" class="alignleft size-full wp-image-11150" /><br />
<hr />
出现这个问题的原因是由于expdp不会导出sys中对象,所以就丢失了这部分授权信息,可以通过获取语句获取权限,然后执行补全</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select 'grant ' || privilege || ' on ' ||'&quot;'||table_name ||'&quot;'||
  2        ' to ' || grantee || ';' &quot;GRANTS&quot;
  3   from dba_tab_privs
  4  where owner = 'SYS' and privilege not in ('READ', 'WRITE')
  5    and grantee in ('XFF')
  6  order by 1;

GRANTS
--------------------------------------------------------------------------------
grant EXECUTE on &quot;DBMS_LOCK&quot; to XFF;
grant SELECT on &quot;OBJ$&quot; to XFF;
grant SELECT on &quot;V_$SESSION&quot; to XFF;
</pre>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/01/impdp-create-index-ora-00942.html" rel="bookmark" class="crp_title">impdp 创建index提示ORA-00942: table or view does not exist</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/05/%e5%85%b3%e4%ba%8eoracle-11g%e5%af%86%e7%a0%81%e5%a4%a7%e5%b0%8f%e5%86%99%e6%95%8f%e6%84%9f%e7%8c%9c%e6%83%b3user-spare4.html" rel="bookmark" class="crp_title">关于ORACLE 11G密码大小写敏感猜想(USER$.SPARE4)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/03/ora-39773.html" rel="bookmark" class="crp_title">ORA-39773: parse of metadata stream failed故障处理</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/data-pump-%e4%b8%adnetwork_link%e5%8f%82%e6%95%b0%e7%9a%84%e4%bd%bf%e7%94%a8.html" rel="bookmark" class="crp_title">Data pump 中network_link参数的使用</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/data-pump-%e4%b8%adnetwork_link%e5%8f%82%e6%95%b0%e7%9a%84%e4%bd%bf%e7%94%a8%e7%bb%ad%e7%99%bb%e5%bd%95%e7%94%a8%e6%88%b7%e5%92%8c%e6%ba%90%e7%ab%af%e7%94%a8%e6%88%b7%e4%b8%8d%e4%b8%80%e8%87%b4.html" rel="bookmark" class="crp_title">Data pump 中network_link参数的使用续(登录用户和源端用户不一致处理)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2015/10/exp-00104-datatype-binary_double-%e9%94%99%e8%af%af.html" rel="bookmark" class="crp_title">EXP-00104: datatype (BINARY_DOUBLE) 错误</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2015/02/%e7%bb%99%e4%bd%a0%e7%9a%84dmp%e6%96%87%e4%bb%b6datapump%e5%8a%a0%e4%b8%8a%e5%af%86%e7%a0%81%e9%94%81.html" rel="bookmark" class="crp_title">给你的dmp文件(datapump)加上密码锁</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2026/05/ora-39083-ora-14102.html" rel="bookmark" class="crp_title">impdp报ORA-39083 ORA-14102错误处理</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/12/oracle-12c%e5%8f%af%e4%bb%a5%e9%80%9a%e8%bf%87expdp%e5%af%bc%e5%87%baview%e6%95%b0%e6%8d%ae.html" rel="bookmark" class="crp_title">ORACLE 12C可以通过expdp导出view数据</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2017/04/impdp-disable_archive_logging.html" rel="bookmark" class="crp_title">impdp中的DISABLE_ARCHIVE_LOGGING参数测试</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2022/09/devos-db-recovery.html" rel="bookmark" class="crp_title">.Devos加密数据库恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/01/%e9%aa%8c%e8%af%81imp-show%e5%8f%82%e6%95%b0.html" rel="bookmark" class="crp_title">验证imp show参数</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2025/01/impdp-missing-sys-priv.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
