<?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; schema级别授权</title>
	<atom:link href="https://www.xifenfei.com/tag/schema%e7%ba%a7%e5%88%ab%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>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>Oracle23ai新特性&#8212;SCHEMA级授权( grant select any table on schema)</title>
		<link>https://www.xifenfei.com/2024/07/grant-select-any-table-on-schema.html</link>
		<comments>https://www.xifenfei.com/2024/07/grant-select-any-table-on-schema.html#comments</comments>
		<pubDate>Mon, 29 Jul 2024 14:26:15 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[Oracle 23ai]]></category>
		<category><![CDATA[grant select any table on schema]]></category>
		<category><![CDATA[schema级别授权]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=10874</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2024/07/grant-select-any-table-on-schema.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/2024/07/grant-select-any-table-on-schema.html" target="_blank">Oracle23ai新特性&#8212;SCHEMA级授权( grant select any table on schema)</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>创建测试用户a并在a中创建t1,t2两个测试表,另外创建用户b(只授权登录权限)</p>
<pre class="brush: sql; title: ; notranslate">
[oracle@xifenfei ~]$ ss

SQL*Plus: Release 23.0.0.0.0 - for Oracle Cloud and Engineered Systems on Mon Jul 29 22:14:11 2024
Version 23.5.0.24.07

Copyright (c) 1982, 2024, Oracle.  All rights reserved.


Connected to:
Oracle Database 23ai Enterprise Edition Release 23.0.0.0.0 - for Oracle Cloud and Engineered Systems
Version 23.5.0.24.07

SQL&gt; show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 XIFENFEI                       READ WRITE NO

SQL&gt; create user b identified by oracle;

User created.

SQL&gt; grant create session  to b;

Grant succeeded.

SQL&gt; grant unlimited tablespace to a;

Grant succeeded.

SQL&gt; create table a.t1 as select * from dba_objects;

Table created.

SQL&gt; c/t1/t2;
  1* create table a.t2 as select * from dba_objects
SQL&gt; /

Table created.

SQL&gt; select count(1) from a.t1;

  COUNT(1)
----------
     70638

SQL&gt; select count(1) from a.t2;

  COUNT(1)
----------
     70639

SQL&gt; create user b identified by oracle;

User created.

SQL&gt; grant create session  to b;

Grant succeeded.
</pre>
<p>直接使用b用户登录并尝试查询a用户数据,结果是无法查询数据报ora-00942(意料之中因为b现在无权限访问a.t1表)</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; conn b/oracle@127.0.0.1/xifenfei
Connected.
SQL&gt; select count(1) from a.t1;
select count(1) from a.t1
                       *
ERROR at line 1:
ORA-00942: table or view &quot;A&quot;.&quot;T1&quot; does not exist
Help: https://docs.oracle.com/error-help/db/ora-00942/
</pre>
<p>直接schema级别授权a用户下面的表给b用户查询权限</p>
<pre class="brush: sql; title: ; notranslate">
[oracle@xifenfei ~]$ ss

SQL*Plus: Release 23.0.0.0.0 - for Oracle Cloud and Engineered Systems on Mon Jul 29 22:07:14 2024
Version 23.5.0.24.07

Copyright (c) 1982, 2024, Oracle.  All rights reserved.


Connected to:
Oracle Database 23ai Enterprise Edition Release 23.0.0.0.0 - for Oracle Cloud and Engineered Systems
Version 23.5.0.24.07

SQL&gt;  grant select any table on schema a to b;

Grant succeeded.

SQL&gt;  conn b/oracle@127.0.0.1/xifenfei
Connected.
SQL&gt; select count(1) from a.t1;

  COUNT(1)
----------
     70638

SQL&gt; select count(1) from a.t2;

  COUNT(1)
----------
     70639

</pre>
<p>在a用户中新增加表,在b用户中可以直接查询(无需再次授权)</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; conn a/oracle@127.0.0.1/xifenfei
Connected.
SQL&gt;  create table t3 as select * from tab;

Table created.

SQL&gt; select count(1) from t3;

  COUNT(1)
----------
         3

SQL&gt; conn b/oracle@127.0.0.1/xifenfei
Connected.
SQL&gt; select count(1) from a.t3;

  COUNT(1)
----------
         3
</pre>
<p>Oracle 23ai中，Oracle引入了架构级（SCHEMA级别）授权。这允许你以更简单、更直观的方式对整个Schema进行授权。以前的版本中如果需要类似授权操作,需要对schema下面所有表进行grant select on user.table to user2形式授权工作量比较大而且user1中如果新增加表还需要额外授权</p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/01/oracle-user-read-only.html" rel="bookmark" class="crp_title">Oracle read only用户&#8212;23ai新特性:只读用户</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/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/2023/04/update-user-ora-01031.html" rel="bookmark" class="crp_title">update user$报ORA-01031错误</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/10/tts%e5%ae%9e%e7%8e%b0%e8%b7%a8%e7%89%88%e6%9c%ac%e8%bf%81%e7%a7%bb%e6%95%b0%e6%8d%ae.html" rel="bookmark" class="crp_title">TTS实现跨版本迁移数据</a></li><li style="list-style-type:decimal;font-size:11px;" ><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" rel="bookmark" class="crp_title">创建视图提示ORA-01031</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/2024/07/oracle-23ai-install.html" rel="bookmark" class="crp_title">oracle 23ai（23.5.0.24.07）完整功能版安装体验</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/01/impdp-missing-sys-priv.html" rel="bookmark" class="crp_title">impdp导入数据丢失sys授权问题分析</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/12/oracle-10g%e7%bb%95%e8%bf%87%e5%af%86%e7%a0%81%e7%99%bb%e9%99%86%e6%95%b0%e6%8d%ae%e5%ba%93.html" rel="bookmark" class="crp_title">Oracle 10g绕过密码登陆数据库</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/2020/11/19c-root-pdb-undo-lost-recovery.html" rel="bookmark" class="crp_title">模拟19c数据库root pdb undo异常恢复</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2024/07/grant-select-any-table-on-schema.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
