zoukankan      html  css  js  c++  java
  • Oracle命令:授权收回权限角色

    oracle grant

    不论授予何种权限,每条授权(grant)语句总是由三部分组成:

    1) 接受者部分是准备获得权限的一个或多个用户的列表。

    2)关键字权限部分由grant后跟一种或多种权限组成。如果在同一条grant语句中有多个权限,权限之间用逗号分隔。

    3)  表名部分由关键字o n起头并列出准备在其上授权的表。

    看下面的详细介绍,主要是介绍如何把添加、删除、修改、查询四种权限授予用户,如下:

    一、insert

    insert权限允许在其他用户的表中建立行。语句grant insert on sample_a to public;允许所有用户在sample_a中建立新的行。Oracle允许在单条grant语句中授多个权限,SQL语句grant insert,select on sample_a to public;等价于两个语句:grant select on sample_a to public;语句和grant insert on sample_a to ublic;语句。

    二、update

    update权限允许其他用户修改非自己表中的数据。语句grant update on sample_a teplownd;允许用户teplownd修改表sample_a中的信息。

    三、select

    select权限允许用户查看其他用户表中的内容。语句grant select on sample_3 to public;将允许所有用户浏览表sample_3中的内容,而语句grant select on sample_3 to ops$rosenberge,ops$abbeyms;则只允许两个用户查看表sample_3中的内容。注意,当多个用户接受授权时,用户名之间要用逗号分隔。

    提示以public为授权对象时,所有数据库用户都获得指定的权限。如果用户的数据库有15000个用户,则单独授权就需要15000次(每个用户一次),而授权给public,一次即可。

    四、delete

    删除权限允许其他用户删除指定表的信息行。此权限非同小可,因此我们建议小心使用。下面是一个实际例子:如果一个用户连接到产品数据库,而他还以为他连接的是测试数据库。他发布了一条命令delete from people_master;并且Oracle做出了反应12003 rows delet.ed在退出SQL * Plus后,下一个程序访问people_master查看Rick Bower的记录,会被告知记录不存在。

    命令grant delete,update,select on sample_a to public;对所有数据库用户给出指明的权限,而命令grant select,update,insert,delete on sample_a to teplownd,greerw;只允许用户teplownd和greerw对表sample_a做命令中所列出的动作

    授权语句

    --select * from dba_users; 查询数据库中的所有用户

    --alter user TEST_SELECT account lock; 锁住用户 
    --alter user TEST_SELECT account unlock; 给用户解锁

    --create user xujin identified by   xujin; 建立用户

    --grant create tablespace to xujin; 授权 
    --grant select on tabel1 to xujin; 授权查询 
    --grant update on table1 to xujin; 
    --grant execute on procedure1 to xujin 授权存储过程 
    --grant update on table1 to xujin with grant option; 授权更新权限转移给xujin用户,许进用户可以继续授权;

     
    --收回权限

    --revoke select on table1 from xujin1; 收回查询select表的权限; 
    --revoke all on table1 from xujin;


    /*grant connect to xujin; 
    revoke connect from xujin 
    grant select on xezf.cfg_alarm to xujin; 
    revoke select on xezf.cfg_alarm from xujin;*/ 
    --select table_name,privilege from dba_tab_privs where grantee='xujin' 查询一个用户拥有的对象权限 
    --select * from dba_sys_privs where grantee='xujin' 查询一个用户拥有的系统权限 
    --select * from session_privs --当钱会话有效的系统权限

    --角色

    --create role xujin1;--建立xujin1角色 
    --grant insert on xezf.cfg_alarm to xujin1; 将插入表的信息 
    --revoke insert on xezf.cfg_alarm from xujin1; 收回xujin1角色的权限 
    --grant xujin1 to xujin ; 将角色的权限授权给xujin; 
    -- create role xujin2; 
    --grant xujin1 to xujin2; 将角色xujin1授权给xujin2; 
    --alter user xujin default xujin1,xujin2; 修改用户默认角色 
    -- DROP ROLE xujin1;删除角色1; 
    --select * from role_sys_privs where role=xujin1; 
    --查看许进1角色下有什么系统权限; 
    --select granted_role,admin_option from role_role_privs where role='xujin2'; 
    --查看xujin1角色下面有什么角色权限 
    --select * from role_sys_privs where role='xujin2'; 
    --select table_name,privilege from role_tab_privs where role='xujin1'; 
    --select * from dba_role_privs where grantee='xujin' --查看用户下面有多少个角色;

    出处:http://greatwqs.iteye.com/blog/1061510

  • 相关阅读:
    SQL Server 2012 自动增长列,值跳跃问题(自增增加1000)
    根据城市表生成json数据
    LeetCode_257. Binary Tree Paths
    LeetCode_242. Valid Anagram
    LeetCode_237. Delete Node in a Linked List
    LeetCode_235. Lowest Common Ancestor of a Binary Search Tree
    LeetCode_234. Palindrome Linked List
    LeetCode_232. Implement Queue using Stacks
    LeetCode_231. Power of Two
    LeetCode_225. Implement Stack using Queues
  • 原文地址:https://www.cnblogs.com/mq0036/p/2840637.html
Copyright © 2011-2022 走看看