zoukankan      html  css  js  c++  java
  • gen_grant_dml.sql

    set echo off feedback off verify off pagesize 0 linesize 120

    define v_grantee                = &1

    define v_grant_dml_command_file = .loggrant_dml_&v_grantee..sql

    define v_grant_dml_log_file     = .loggrant_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.

  • 相关阅读:
    git subtree用法
    Excel导入、导出库:ExcelKit
    [C#.NET 拾遗补漏]08:强大的LINQ
    使用.net standard实现不同内网端口的互通(类似花生壳)
    LINQ:最终统治了所有的语言!
    浅谈代码段加密原理(防止静态分析)
    HashTable、HashSet和Dictionary的区别(转)
    Mysql分表和分区的区别、分库分表介绍与区别
    划词高亮功能的实现附带开源代码
    十个推荐使用的 Laravel 的辅助函数
  • 原文地址:https://www.cnblogs.com/feiyun8616/p/5897052.html
Copyright © 2011-2022 走看看