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 ...
随机推荐
- 三层交换机配置说明(华为S5700设置三个网段互通)
1.配置Switch # 创建VLAN <HUAWEI> system-view[HUAWEI] sysname Switch[Switch] vlan batch 10 20 30# 配 ...
- linux上安装配置samba服务器
linux上安装配置samba服务器 在linux上安装配置samba服务器 在这给大家介绍一个不错的家伙,samba服务.如果您正在犯愁,如何在Windows和Linux之间实现资源共享,就请看看这 ...
- hdu_2608_0 or 1_数论
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2608 反正我是没找出这个规律的,规律参考的别人的! /* 分析:假设数n=2^k*p1^s1*p2^s ...
- hdu_4734_F(x)(数位DP水)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4734 题意:给你一个F(x)的定义,然后给你a,b,问你在0到b包括b有多少个数满足F(x)<= ...
- Boxes in a Line(移动盒子)
You have n boxes in a line on the table numbered 1 . . . n from left to right. Your task is to sim ...
- sublime 2
just baidu sublime license and find a free one!
- 【超级干货】手机移动端WEB资源整合:转载
转载于:http://www.w3cfuns.com/notes/24611/fbba9cbd616e795360ea45515494aa53.html meta基础知识 H5页面窗口自动调整到设备宽 ...
- c语言编译命令
第14章 预处理及用户配置文件 • 预处理命令通常在程序编译时进行一些符号处 理,其并不执行具体的硬件操作.C51语言中的预 处理命令主要有宏定义指令.文件包指令和条 件编译指令,还有其他一些调试时使 ...
- 使用onclick跳转到其他页面。使用button跳转到指定url
1. onclick="javascript:window.location.href='aa.htm'" 2. onclick="location='URL'&quo ...
- photoshop 魔术橡皮擦
魔术棒和橡皮的结合,不用解锁就能抠图