用户管理

Authentication: 身份验证

AAA:
Authentication: 身份验证

Authorization: 权限管理

Audition: 审计

grant:授权

unset:撤销(消除)

SQL>echo $ORACLE_SID ORCL 查询数据库的名字为ORCL

SQL>vnset ORACLE_SID 删除数据库名字为ORCL

SQL>export ORACLE_SID=ORCL 重新添加变量数据库的名字为ORCL

管理员的身份验证:
本地连接:
本地连接,预先设置ORACLE_SID,操作系统用户是dba群组的成员

id
uid=1001(oracle) gid=1000(oinstall) groups=1000(oinstall),1031(dba),1032(oper)
$ sqlplus / as sysdba
SQL> show user
USER is "SYS"
$ su -
# usermod -G oper oracle 或 -G:附加群组 -g:主群组 -d:删除 -a:添加
# gpasswd -d oracle dba
# exit
$ sqlplus / as sysdba
报错,权限不够

只要是dba群组中的成员,就可以不需要知道sys的口令,直接以sqlplus / as sysdba登录
并且身份为sys。

恢复:
# gpasswd -a oracle dba

远程客户端连接:
$ sqlplus sys/password@orcl as sysdba
$ ls $ORACLE_HOME/dbs/orapworcl
$ orapwd

操作系统中创建用户:
$ su -
Password:
[root@node1 ~]# useradd osuser
[root@node1 ~]# passwd osuser
$ sqlplus / as sysdba
外部用户使用固定的前缀:
SQL> show parameter os_auth
SQL> create user ops$osuser identified externally;
SQL> grant create session to ops$osuser;
不要su - osuser,环境变量保留:
$ su osuser
Password:
[osuser@node1 admin]$ sqlplus /
SQL> show user
USER is "OPS$OSUSER"

或者用命令创建:
SQL> create user user01 identified by password;
SQL> grant create session to user01; grant:授权

测试:
$ sqlplus user01/password

authorization:(权限管理)

预先创建测试表
SQL> create table t1(x int);
SQL> create user user01 identified by password;
SQL> grant create session to user01;★
SQL> grant select any table to user01;★

user01测试:
$ sqlplus user01/password
SQL> select count(*) from hr.employees(hr.departments scott.emp);
SQL> delete from scott.emp; 失败!
SQL> select * from sys.t1; 失败!

select any table n-1模式 注:(any不包括sys)★★
sys再次授权:
SQL> grant select any dictionary to user01;
user01测试:
SQL> select * from sys.t1; 成功
select any table(n-1)+select any dictionary(1)
sys授权:
SQL> grant create table to user01;
user01测试:
SQL> create table t1(x int);
sys授权:
SQL> grant unlimited tablespace to user01;
user01测试:
SQL> insert into t1 values (1);

对象权限:关键字为“on”

sys授权:
SQL> grant select on hr.employees to user01;
user01测试:
SQL> select count(*) from hr.employees;
SQL> delete from hr.employees; 失败
SQL> select count(*) from hr.departments; 失败
sys授权:
SQL> grant index on hr.employees to user01;
SQL> grant unlimited tablespace to user01;
user01测试:
SQL> create index emp_sal_idx on hr.employees(salary);
SQL> select index_name from user_indexes where table_name='EMPLOYEES';

create any table 系统级别的选项,能在任何一个模式下创建表 create table 系统级别的选项,权限也为系统的
alter any table 系统级别的权限,能修改任何一张表(any不包括sys) alter table 对象权限
drop any table 系统级别的权限 ,能删除任何一张表 drop table 没有权限

权限的级联删除:
系统权限:
sys准备工作:
SQL> drop user user01 cascade;
SQL> drop user user02 cascade;
SQL> create user user01 identified by password;
SQL> create user user02 identified by password;
SQL> grant create session to user01;
SQL> grant create session to user02;
sys授权:
SQL> grant select any table to user01 with admin option;
user01测试成功并授权给user02:
SQL> select count(*) from hr.employees;
SQL> grant select any table to user02 with admin option;
user02测试成功:
SQL> select count(*) from hr.employees;
sys收回权限:
SQL> revoke select any table from user01;
user01操作失败:
SQL> select count(*) from hr.employees;
user02测试成功:
SQL> select count(*) from hr.employees;
对象权限:
SQL> grant select on hr.employees to user01 with grant option;

dba+sysdba=sys

revoke:收回(收回权限)

预定义的角色:
SQL> select role from dba_roles;
创建角色:
SQL> create role hr_mgr;
SQL> create role hr_clerk;
SQL> grant select any table to hr_mgr;
SQL> grant select on hr.employees to hr_clerk;
SQL> grant hr_mgr to user01;
SQL> grant hr_clerk to user02;
user01/user02测试:
角色生效必须重新登录

audit(审计)

开启开关参数:
SQL> show parameter audit_trail

设置审计选项:
每次设置新的审计选项,测试用户需要重新连接
sys准备工作:
SQL> drop user user01 cascade;
SQL> create user user01 identified by password;
SQL> grant create session, create table, create any table to user01;

Oracle课程档案,第十天的更多相关文章

  1. Oracle课程档案,第十六天

    restore:恢复文件 recover: 恢复日志 丢失current日志组(正常关闭数据库):故障:SQL> select group#, status from v$log; 确认curr ...

  2. Oracle课程档案,第十四天

    备份数据文件:SQL> select file_id, file_name from dba_data_files; backup:备用(备份) datafile:数据文件 backup tab ...

  3. Oracle课程档案,第十五天

    restore:恢复数据文件 recover:写日志 1.redo(roll forward)重做 (前进) 2.undo(roll back) 撤销 (回滚) cp -r:删除一个目录 archiv ...

  4. Oracle课程档案,第十七天

    flashback drop 闪回下降(删除)SQL> show parameter recyclebinSQL> purge recyclebin;(清除回收站)SQL> crea ...

  5. Oracle课程档案,第十三天

    配置可恢复性: ontrol_files:控制文件 parameter:参数 show:显示 select name from v$database; 查看当前的数据库★★ 控制文件SQL> s ...

  6. Oracle课程档案,第十二天

    死锁是由于两个对象在拥有一份资源的情况下申请另一份资源, 而另一份资源恰好又是这两对象正持有的,导致两对象无法完成操作,且所持资源无法释放. 阻塞是由于资源不足引起的排队等待现象. unso:撤销 c ...

  7. Oracle课程档案。第十一天

    读一致性:oracle通过多版本与闪回机制保证读一致性.保证从某个时间点开始查询是一致的.在Oracle中主要通过SCN版本号来控制系统修改的版本,典型的例子是我们可以通过在同一个查询中得到同一个对象 ...

  8. Oracle课程档案,第九天

    lsnrctl status:查看监听状态 Oracle网络配置三部分组成:客户端,监听,数据库 配置文件:$ vi $ORACLE_HOME/network/admin/listener.ora v ...

  9. Oracle课程档案,第八天

    存储管理 查询块的大小:show parameter db_block_size database:数据库 tablespace:表空间 datafile:数据文件 segments:段 extent ...

随机推荐

  1. Dubbo接口压测

    在每年的双十一大促之前,除了全链路压测,还需要各个业务方对自己业务提供的核心接口进行单接口压测,以评判系统的稳定性和承压能力. 一.准备工作 环境准备:确保应用性能环境(perf)正常可用 压测接口梳 ...

  2. requirejs整合ztree

    {block name='script'} <script> require(['jquery.ztree'], function () { var zTreeObj; var setti ...

  3. protobuf 动态创建

    https://www.ibm.com/developerworks/cn/linux/l-cn-gpb/index.html https://originlee.com/2015/03/14/ana ...

  4. intellij 自动导包

  5. 每天一个linux命令(9):touch

    1.命令简介 touch命令将每个文件的访问时间和修改时间改为当前时间. 2.用法 touch [选项]... 文件... 3.选项 -a 只更改访问时间 -c, --no-create 不创建任何文 ...

  6. git主要操作命令

    1.创建版本库 (1)初始化一个 Git仓库,使用git init命令 (在相应的本地库目录下执行,将该目录初始化为一个Git库): (2)添加文件到Git仓库,分两步: 第一步,使用命令 git a ...

  7. 记一次免费让网站启用HTTPS的过程

    写在前面 个人网站运行将近2个月了,期间根据酷壳的一篇教程如何免费的让网站启用HTTPS做了一次,中间遇到问题就放下了.昨天孙三苗问我网站地址说要添加友链,出于好奇想看他网站长什么样,顺道也加一下友链 ...

  8. Spring Boot系列——AOP配自定义注解的最佳实践

    AOP(Aspect Oriented Programming),即面向切面编程,是Spring框架的大杀器之一. 首先,我声明下,我不是来系统介绍什么是AOP,更不是照本宣科讲解什么是连接点.切面. ...

  9. Git命令速查表

  10. hadoop 动态调整mapred参数

    bin/hadoop job -set-reduce-capacity job_20151126032920_1142443 1000 调成map数 bin/hadoop job -set-prior ...