Home > Database > Mysql Tutorial > Oracle 创建监控账户 提高工作效率

Oracle 创建监控账户 提高工作效率

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 18:06:35
Original
941 people have browsed it

有很多Oracle服务器,需要天天查看TableSpace,比较麻烦了。

为了把事情变成简单化,我在多个Oracle数据上建立统一的检查数据库账户,并且账户只能访问特定的几个视图(需要查询的sql已生成视图),具体做法如下:

root>sqlplus / as sysdba
用DBA的权限进入数据库,需要创建一个账户
http://www.jb51.net/article/20367.htm

SQL>create user dbmonitor identified by "ty_sd_s";
给账户授权
SQL>grant connect,resource to dbmonitor;

此账户执行的脚本转换成视图
代码如下:
SQL> drop view vstablespace;
SQL> create view vstablespace as
(
select
a.tablespace_name "TABLESPACE",
sum(a.bytes) SUM ,
sum(b.bytes) FREE ,
sum(b.bytes)/sum(a.bytes)*100 PRECENTFREE
from
dba_data_files
a,dba_free_space b
where
a.file_id=b.file_id
group by a.tablespace_name
)


给用户赋予select试图的权限
SQL>grant select on vstablespace to dbmonitor ;

如此下来,这个用户只能查看此数图,不能改动其他的,就可以保证数据库的安全了

退出,再用新建的oracle账户登录
root>sqlplus dbmonitor/"ty_sd_s" as sysdba;
进入之后查看用户所赋予的权限
SQL>select * from user_tab_privs;

从这里看到只用新建视图的权限
SQL>select * from sys.vstablespace ;
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template