gen_grant_sel.sql
set echo off feedback off verify off pagesize 0 linesize 120
define v_grantee=&1
define v_grant_sel_command_file = .\log\grant_sel_&v_grantee..sql
define v_grant_sel_log_file = .\log\grant_sel_&v_grantee..log
spool &v_grant_sel_command_file.
prompt spool &v_grant_sel_log_file.
prompt set echo on feedback on
prompt show user
----将原有的权限赋予用户,no exsists ( select null于(select *)差不多) 就是where如果子查询没有返回行,则----则满足 NOT EXISTS 中的 ----WHERE 子句,目的应该是检查是否表的权限是否有丢失。
----按照每个表的权限进行遍历
select
'grant select on ' || t.table_name || ' to &v_grantee with grant option;'
from user_tables t
where not exists
(select null
from user_tab_privs p
where p.owner = user
and p.table_name = t.table_name
and p.grantee = upper('&v_grantee'))
and user != upper('&v_grantee')
order by t.table_name
/
--
select
'grant select on ' || v.view_name || ' to &v_grantee with grant option;'
from user_views v
where not exists
(select null
from user_tab_privs p
where p.owner = user
and p.table_name = v.view_name
and p.grantee = upper('&v_grantee'))
and user != upper('&v_grantee')
order by v.view_name
/
select
'grant execute on ' || o.object_name || ' to &v_grantee;'
from user_objects o
where object_type in ('PACKAGE')
and not exists
(select null
from user_tab_privs p
where p.owner = user
and p.table_name = o.object_name
and p.grantee = upper('&v_grantee'))
and user != upper('&v_grantee')
order by o.object_name
/
prompt set echo off feedback off
prompt spool off
spool off
@&v_grant_sel_command_file.
补充测试说明:
data user: for ddl usr
user: for app dml/select (同义词)
patch user: for app supprot user (同义词)
query : for app supprot user (同义词)
##
step 1:
检查 data user的表是否给了权限usr user.
变量为: dbUSR
select * from user_tab_privs p where p.owner = user and p.grantee = upper('&v_grantee')) and user != upper('&v_grantee')
step 2.1: 测试取消data user 的表的update/select权限
revoke update on testfrom dbUSR; revoke select on testfrom dbUSR;
step 3.1: 测试脚本01_schema_rollout.sql能否将的表的update/select权限 重新授权
测试01_schema_rollout.sql 结果:无法将2个权限 重新授权
step 2.2: 测试取消data user 的表的delete/insert权限
revoke insert on testfrom dbUSR;
revoke delete on testfrom dbUSR;
step 3.2: 测试脚本能否将的表的delete/insert/update/select权限 重新授权
测试01_schema_rollout.sql 结果:可以
step 2.3 删除一个表。然后使用备份表(.sql)文件恢复,是可行的。(.sql 文件包含授权grant命令 )
step 3.3 同义词 状态是invalide,可以忽略。
原因如下: 先建一个可用的同义词,然后将该同义词对应的表删除,dba_objects对应的状态就是INVALID了 然后当你再去select这个同义词的时候,status又会变成VALID.
gen_grant_sel.sql的更多相关文章
- call_grant_sel.sql
set echo offpromptprompt =========================================================================== ...
- 最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目
最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目 最近一个来自重庆的客户找到走起君,客户的业务是做移动互联网支付,是微信支付收单渠道合作伙伴,数据库里存储的是支付流水和交易流水 ...
- SQL Server 大数据搬迁之文件组备份还原实战
一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 解决方案(Solution) 搬迁步骤(Procedure) 搬迁脚本(SQL Codes) ...
- Sql Server系列:分区表操作
1. 分区表简介 分区表在逻辑上是一个表,而物理上是多个表.从用户角度来看,分区表和普通表是一样的.使用分区表的主要目的是为改善大型表以及具有多个访问模式的表的可伸缩性和可管理性. 分区表是把数据按设 ...
- SQL Server中的高可用性(2)----文件与文件组
在谈到SQL Server的高可用性之前,我们首先要谈一谈单实例的高可用性.在单实例的高可用性中,不可忽略的就是文件和文件组的高可用性.SQL Server允许在某些文件损坏或离线的情况下,允 ...
- EntityFramework Core Raw SQL
前言 本节我们来讲讲EF Core中的原始查询,目前在项目中对于简单的查询直接通过EF就可以解决,但是涉及到多表查询时为了一步到位就采用了原始查询的方式进行.下面我们一起来看看. EntityFram ...
- 从0开始搭建SQL Server AlwaysOn 第一篇(配置域控)
从0开始搭建SQL Server AlwaysOn 第一篇(配置域控) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://www.cnb ...
- 从0开始搭建SQL Server AlwaysOn 第二篇(配置故障转移集群)
从0开始搭建SQL Server AlwaysOn 第二篇(配置故障转移集群) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://www ...
- 从0开始搭建SQL Server AlwaysOn 第三篇(配置AlwaysOn)
从0开始搭建SQL Server AlwaysOn 第三篇(配置AlwaysOn) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://w ...
随机推荐
- 小飞淙在博客上的第一天——NOIP201505转圈游戏
原本我是在word文档上写这种东西的,在杨老师的“强迫”下,我开始写了博客. 这是我在博客上的第一天,就先来个简单的,下面请看题: 试题描述 有n个小伙伴(编号从0到n-1)围坐一圈玩游戏.按照顺时 ...
- iosiOSlabel基本使用以及文字自适应
(如果需要的不是使用的属性值如换行形式,可以把对应的属性在程序中书写然后按"command"+鼠标左键点击就可以查看所有属性值) 一label基本设置 self.view.back ...
- inflate的使用注意事项
public View inflate (int resource, ViewGroup root, boolean attachToRoot) 我们在使用这个方法时,要清楚原理,下面是这个方法的文档 ...
- 使用 Flex 库项目---打包swc
来源:http://help.adobe.com/zh_CN/flashbuilder/using/WSe4e4b720da9dedb5-1a92eab212e75b9d8b2-7ffe.html ...
- http response
关键词:http response header 下载文件 案例1: 访问某个链接,然后下载文件,需要特定的http头: header("Content-Type:application/z ...
- shell之路【第二篇】运算与文件调用
Bash 支持很多运算符,包括算数运算符.关系运算符.布尔运算符.字符串运算符和文件测试运算符. 原生bash不支持简单的数学运算,默认都是字符串操作,但是可以通过其他命令来实现 算数运算 expr. ...
- blob的存储与读取
对于oracle数据库的blob的存储与读取对应的是byte数组. 将blob类型数据存入数据库: String blob: byte[] byte = blob.getBytes(); entity ...
- 用caffe给图像的混乱程度打分
Caffe应该是目前深度学习领域应用最广泛的几大框架之一了,尤其是视觉领域.绝大多数用Caffe的人,应该用的都是基于分类的网络,但有的时候也许会有基于回归的视觉应用的需要,查了一下Caffe官网,还 ...
- Apache开启gzip压缩传输
修改Apache配置文件 第一步,添加两个模块 LoadModule deflate_module modules/mod_deflate.so LoadModule headers_module m ...
- overlay
http://dockone.io/article/237 http://blog.cloud66.com/docker-with-overlayfs-first-impression/ http:/ ...