Oracle权限常用语句【转】

http://www.cnblogs.com/ningvsban/p/3606239.html body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe WPC', 'Segoe UI', 'HelveticaNeue-Light', 'Ubuntu', 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.6; }

Oracle用户权限常用语句

常用的System Privileges

  • create session 连接数据库
  • create table 建表
  • create view 建视图
  • create public synonym 建同义词
  • create procedure 建过程、函数、包
  • create trigger 建触发器
  • create cluster 建簇

实例

创建用户并赋予该用户授权权限。

成都创新互联是一家专注于成都做网站、网站设计与策划设计,临河网站建设哪家好?成都创新互联做网站,专注于网站建设10多年,网设计领域的专业建站公司;建站业务涵盖:临河等地区。临河做网站价格咨询:18982081108

create user ken identified by ken;

授予权限并附带admin option

grant create session, create table to ken with admin option;

授予权限,不带with admin option

grant create view to ken;

新建tom用户

create user tom identified by tom;

使用ken用户登录后对tom授权, 语句执行成功

grant create session, create table to tom; Grant succeeded. 对tom授权,语句执行失败 grant create view to tom; grant create view to tom * ERROR at line 1: ORA-01031: insufficient privileges

回收权限

note 注意,回收权限不是级联的。

从ken回收登录权限

revoke create session from ken;

此时tom依然可以登录,但Ken无法登录了

ERROR: ORA-01045: user KEN lacks CREATE SESSION privilege; logon denied

常用的Object Privilege

  • alter
  • delete
  • select
  • insert
  • update
  • index
  • references
  • execute
查看系统中的Object Privilege

select distinct privilege from dba_tab_privs;

查看某用户具有的Object Privilege

select grantor, owner, table_name, privilege from dba_tab_privs where grantee = 'TOM';

授予人可以是该对象所有者或者sys和system用户。

grant select on t to tom

授予所有权限

grant all on emp to monkey;

授予列权限

grant update on emp(sal) to monkey

授予对于某个包的执行权限

grant execute on dbms_transaction to ken;

在别的schema中建立索引,必须具备以下权限

grant index on scott.emp to blake;

回收对象权限

revoke select on emp from blake

note 回收Object Privilege 会导致级联回收。

角色

角色Role,定义一组权限。

查询角色具备的权限

select * from role_sys_privs where role='角色名'

select * from role_sys_privs where role='CONNECT';

select * from role_sys_privs where role='RESOURCE';

DBA角色

dba角色具有所有的系统权限,及with admin option选项,默认的dba用户为sys和system,它们可以将任何系统权限授予其他用户。但是要注意的是dba角色不具备sysdba和sysoper的特权(启动和关闭数据库)

note 一般而言,创建用户后,给与connect角色和resource就够了。

自定义角色

建立角色(不验证)

create role 角色名 not identified;

建立角色(数据库验证)

create role 角色名 identified by 密码;

角色授权

grant create session to 角色名 with admin option grant select on scott.emp to 角色名; grant insert, update, delete on scott.emp to 角色名;

分配角色

grant 角色名 to blake with admin option;

select * from dba_roles;

select privilege, admin_option from role_sys_privs where role='角色名';

select granted_role, default_role from dba_role_privs where grantee = '用户名';

文章名称:Oracle权限常用语句【转】
URL链接:https://www.cdcxhl.com/article28/ghhjjp.html

成都网站建设公司_创新互联,为您提供企业建站App设计静态网站App开发小程序开发网站内链

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都app开发公司