set echo off feedback off verify off pagesize 0 linesize 120

define v_grantee                = &1

define v_grant_dml_command_file = .\log\grant_dml_&v_grantee..sql

define v_grant_dml_log_file     = .\log\grant_dml_&v_grantee..log

spool &v_grant_dml_command_file.
prompt spool &v_grant_dml_log_file.
prompt set echo on feedback on
prompt show user
select
  'grant select,insert,update,delete on ' || t.table_name || ' to &v_grantee;'
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;'
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 select on ' || s.sequence_name || ' to &v_grantee;'
from     user_sequences s
where not exists
  (select null
   from   user_tab_privs p
   where  p.owner      = user
   and    p.table_name = s.sequence_name
   and    p.grantee    = upper('&v_grantee'))
and user != upper('&v_grantee')
order by s.sequence_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_dml_command_file.

gen_grant_dml.sql的更多相关文章

  1. call_grant_dml.sql

    set echo offpromptprompt =========================================================================== ...

  2. 最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目

    最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目 最近一个来自重庆的客户找到走起君,客户的业务是做移动互联网支付,是微信支付收单渠道合作伙伴,数据库里存储的是支付流水和交易流水 ...

  3. SQL Server 大数据搬迁之文件组备份还原实战

    一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 解决方案(Solution) 搬迁步骤(Procedure) 搬迁脚本(SQL Codes) ...

  4. Sql Server系列:分区表操作

    1. 分区表简介 分区表在逻辑上是一个表,而物理上是多个表.从用户角度来看,分区表和普通表是一样的.使用分区表的主要目的是为改善大型表以及具有多个访问模式的表的可伸缩性和可管理性. 分区表是把数据按设 ...

  5. SQL Server中的高可用性(2)----文件与文件组

        在谈到SQL Server的高可用性之前,我们首先要谈一谈单实例的高可用性.在单实例的高可用性中,不可忽略的就是文件和文件组的高可用性.SQL Server允许在某些文件损坏或离线的情况下,允 ...

  6. EntityFramework Core Raw SQL

    前言 本节我们来讲讲EF Core中的原始查询,目前在项目中对于简单的查询直接通过EF就可以解决,但是涉及到多表查询时为了一步到位就采用了原始查询的方式进行.下面我们一起来看看. EntityFram ...

  7. 从0开始搭建SQL Server AlwaysOn 第一篇(配置域控)

    从0开始搭建SQL Server AlwaysOn 第一篇(配置域控) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://www.cnb ...

  8. 从0开始搭建SQL Server AlwaysOn 第二篇(配置故障转移集群)

    从0开始搭建SQL Server AlwaysOn 第二篇(配置故障转移集群) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://www ...

  9. 从0开始搭建SQL Server AlwaysOn 第三篇(配置AlwaysOn)

    从0开始搭建SQL Server AlwaysOn 第三篇(配置AlwaysOn) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://w ...

随机推荐

  1. bootstrap ch2清除浮动

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name ...

  2. html_web存储

    HTML5存储 HTML5 web存储,一个比cookie更好的本地存储方式. 什么是HTML5 Web存储? 使用HTML5可以在本地存储用户的浏览数据. 早些时候,本地存储使用的是cookie.但 ...

  3. yaf for ubuntu安装

    一.安装yaf需要的扩展 apt-get install perl-modules apt-get install libpcrecpp0 apt-get install libpcre3 libpc ...

  4. Java中String转换Double类型 Java小数点后留两位

    Java中String转换Double类型 double num1 = 0.0; String qq = "19.987"; num1 = Double.valueOf(qq.to ...

  5. android动态添加TextView或者ImageView

    动态添加 text1=new TextView(this); text1.setText("动态添加"); ((LinearLayout) this.findViewById(R. ...

  6. mysql -- 备忘

    select distinct(authorid),author from forum_post where tid=1;

  7. 二分 Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) D

    http://codeforces.com/contest/722/problem/D 题目大意:给你一个没有重复元素的Y集合,再给你一个没有重复元素X集合,X集合有如下操作 ①挑选某个元素*2 ②某 ...

  8. C: Run a System Command and Get Output? 在C程序中调用工具,并且得到结果。

    现在在做一个WIFI API相关的库,这样就可以让其他的人管理WIFI. 在调用API的时候要回复SHELL打印的信息,比如说搜索热点,而且不在SHELL中打印出来.然后把信息返回给调用API的程序. ...

  9. runtime——消息机制

    本文授权转载,作者:Sindri的小巢(简书) 从异常说起 我们都知道,在iOS中存在这么一个通用类类型id,它可以用来表示任何对象的类型 —— 这意味着我们使用id类型的对象调用任何一个方法,编译器 ...

  10. EXP AND IMP

    purpors: exp pro data to uat data exp and imp will not create user expdp and impdp will create user ...