ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 使用SQL批量查询出创建用户及权限脚本

使用SQL批量查询出创建用户及权限脚本

原创 Linux操作系统 作者:tolywang 时间:2012-12-20 08:51:06 0 删除 编辑
 select 'create user ' || a.username || '  identified by "' ||
       (select password from sys.user$ b where a.username = b.name) || '" ' ||
       chr(10) || ' default tablespace  ' || a.default_tablespace ||
       chr(10) || ' temporary tablespace ' || a.temporary_tablespace ||
       chr(10) || ' profile ' || a.profile || ';'
  from dba_users a  
 union all
 select 'grant unlimited tablespace to  ' || a.username || ';'
  from dba_users a   ; 
 
 
select ' grant ' || t.privilege || ' on ' || owner || '.' || table_name ||
        ' to ' || grantee || case
          when grantable = 'YES' then
           ' with grant option;'
          else
           ';'
        end
   from dba_tab_privs t
  where grantee = 'DMCARR';
 

SELECT 'grant ' || granted_role || ' to ' || grantee || case
             when admin_option = 'YES' THEN
              'with admin option;'
             ELSE
              ';'
           end,
           default_role
      FROM DBA_ROLE_PRIVS
     WHERE GRANTEE = 'DMCARR'
     order by default_role;
  select 'grant ' || privilege || ' to ' || grantee || case
           when admin_option = 'YES' THEN
            'with admin option;'
           ELSE
            ';'
         end
    from dba_sys_privs
   where grantee = 'DMCARR';    

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/35489/viewspace-754483/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle , MySQL, SAP IQ, SAP HANA, PostgreSQL, Tableau 技术讨论,希望在这里一起分享知识,讨论技术,畅谈人生 。

注册时间:2007-12-10

  • 博文量
    5595
  • 访问量
    14695403