Oracle(4)创建用户,分配权限及角色,Schema概念

来源:互联网 发布:php cookie 跨域 编辑:程序博客网 时间:2024/06/03 06:35
--创建普通用户 create user 用户名 identified by 密码(密码不能以数字开头)--刚创建的用户没有任何权限,需要管理员分配相应的权限create user jiaozl1 identified by m111111; --- 由于权限等问题,不能立即使用此账户登录--更改密码(密码忘记的情况下可以这样更改密码)  alter user 用户名 identified by 新密码;alter user jiaozl1 identified by m111111;
--创建用户的细节    默认表空间 临时表空间 表空间最大使用空间大小3MBcreate user jiaozl2 identified by m111111             default tablespace users             temporary tablespace temp             quota 3m on users;--分配权限给用户  grant 权限 to 用户名;grant create session to jiaozl2;

————————————————————————————————–

  1. 权限主要分为两种:系统权限(100多种)和对象权限。
    系统权限是和数据库管理相关的权限:
create sessioncreate tablecreate indexcreate viewcreate sequencecreate trriger......

对象权限是和用户操作数据对象相关的权限:

update tableinsert del select 

2 . 角色分为:预定义角色和自定义角色
预定义角色:把常用的权限集中起来,形成角色

dbaconnectresource

自定义角色:自己定义的权限集合

————————————————————————–

create user xiaohong  identified by m123grant connect, resource to xiaohong; -- 分配登录和资源权限create table users(id number);insert into users values(1);select * from users;revoke connect from xiaohong; ------revoke resource from xiaohong; ------ 回收(撤销)权限或角色drop user xiaohong; ---删除用户(如果用户已经创建过数据对象,需要在用户名后加选项cascade,表示将用户与其创建的对象一并删除掉)

3 . 方案(Schema)
方案<—->用户

--scott用户将权限分配给xiaohonggrant select on emp to xiaohong;--执行select时需要指定是哪一个Schemaselect * from scott.emp;
---scott将权限给xiaohong,同时,xiaohong可以将权限转给xiaominggrant select on emp to xiaohong with grant option;---用户权限用:with grant option---系统权限用:with admin option
0 0
原创粉丝点击