Oracle课程档案,第十天
用户管理
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课程档案,第十天的更多相关文章
- Oracle课程档案,第十六天
restore:恢复文件 recover: 恢复日志 丢失current日志组(正常关闭数据库):故障:SQL> select group#, status from v$log; 确认curr ...
- Oracle课程档案,第十四天
备份数据文件:SQL> select file_id, file_name from dba_data_files; backup:备用(备份) datafile:数据文件 backup tab ...
- Oracle课程档案,第十五天
restore:恢复数据文件 recover:写日志 1.redo(roll forward)重做 (前进) 2.undo(roll back) 撤销 (回滚) cp -r:删除一个目录 archiv ...
- Oracle课程档案,第十七天
flashback drop 闪回下降(删除)SQL> show parameter recyclebinSQL> purge recyclebin;(清除回收站)SQL> crea ...
- Oracle课程档案,第十三天
配置可恢复性: ontrol_files:控制文件 parameter:参数 show:显示 select name from v$database; 查看当前的数据库★★ 控制文件SQL> s ...
- Oracle课程档案,第十二天
死锁是由于两个对象在拥有一份资源的情况下申请另一份资源, 而另一份资源恰好又是这两对象正持有的,导致两对象无法完成操作,且所持资源无法释放. 阻塞是由于资源不足引起的排队等待现象. unso:撤销 c ...
- Oracle课程档案。第十一天
读一致性:oracle通过多版本与闪回机制保证读一致性.保证从某个时间点开始查询是一致的.在Oracle中主要通过SCN版本号来控制系统修改的版本,典型的例子是我们可以通过在同一个查询中得到同一个对象 ...
- Oracle课程档案,第九天
lsnrctl status:查看监听状态 Oracle网络配置三部分组成:客户端,监听,数据库 配置文件:$ vi $ORACLE_HOME/network/admin/listener.ora v ...
- Oracle课程档案,第八天
存储管理 查询块的大小:show parameter db_block_size database:数据库 tablespace:表空间 datafile:数据文件 segments:段 extent ...
随机推荐
- iis url重写
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.we ...
- TensorFlow实战Google深度学习框架5-7章学习笔记
目录 第5章 MNIST数字识别问题 第6章 图像识别与卷积神经网络 第7章 图像数据处理 第5章 MNIST数字识别问题 MNIST是一个非常有名的手写体数字识别数据集,在很多资料中,这个数据集都会 ...
- <转>SQL Server CROSS APPLY and OUTER APPLY
Problem SQL Server 2005 introduced the APPLY operator, which is like a join clause and it allows joi ...
- java mqtt
代码: package cc.gongchang.mqtt; import java.net.URISyntaxException; import org.fusesource.hawtdispatc ...
- Linux(CentOS)安装Node.JS和npm的两种方式(yum安装和源码安装)
yum安装 yum安装是将yum源中的rpm包下载到本地,安装这个rpm包.这个rpm包是别人编译安装好的二进制包.这种方式方便快捷,特别是不用考虑包依赖. 0.了解linux版本 通过 uname ...
- Python的虚拟机安装已经如何配置Scrapy for Mac
时间:2018年2月21日 因为时间问题,以下笔记就粗略记录.仅作为个人笔记为用 安装virtualenv和virtualenvwrapper 如何安装的细节下面这篇也有介绍,包括如何使用切换虚拟机也 ...
- SNF快速开发平台2018-移动端代码生成器已发布
各位小伙伴期待已久的移动端已经推出,在此基础上我们又进行配套了代码生成器,以达到高速开发,简化代码等优点. 当然也需要有强大的组件库及标准程序的支撑,同时要有强大的后台做后盾来达到移动端强大功能的施展 ...
- 为github公开项目单独设置用户名
背景: 由于在公司git的配置是公司内自己的用户id及邮箱,如果用同样的配置在github上提交公开项目,可能造成用户名及邮箱泄露,因此对于github上的项目,最好单独设置用户名,而每次在向gith ...
- 【计算机网络】OSI七层模型图解
1.物理层 建立.维护.断开物理连接.(由底层网络定义协议) 2.数据链路层 建立逻辑连接.进行硬件地址寻址.差错校验等功能.(由底层网络定义协议) 将比特组合成字节进而组合成帧,用MAC地址访问介质 ...
- 怎么让Windows2012和Windows2008多用户同时远程---经过测试有效
链接地址:https://jingyan.baidu.com/article/cd4c2979f19765756e6e60ec.html 怎么让Windows2012和Windows2008多用户同时 ...