三、数据字典和动态性能视图的介绍
1. 数据库的数据字典
(1) DBA_ 全库所有的某种对象的数据字典
只有系统用户才有权限查询
(2) ALL_ 当前用户创建的对象 + 其他用户授予当前用户使用的对象
当前用户
(3) USER_ 当前用户创建的对象
当前用户
操作实例:
解锁一个用户hr并改密码
SQL> alter user hr account unlock;
User altered.
SQL> alter user hr identified by hr;
User altered.
在scott用户下,查看hr用户下的表
SQL> conn scott/scott;
Connected.
SQL> select * from hr.jobs;
select * from hr.jobs
*
ERROR at line 1:
ORA-00942: table or view does not exist --报错,表或视图不存在
SQL> conn hr/hr
Connected.
SQL> grant select on jobs to scott; --授予select权限
Grant succeeded.
SQL> insert into hr.jobs values(‘HR_REP‘,‘asdfasd‘,1232,5545);
insert into hr.jobs values(‘HR_REP‘,‘asdfasd‘,1232,5545)
*
ERROR at line 1:
ORA-01031: insufficient privileges
在某个用户下:以下语句是等效的:
select * from user_objects where object_type=‘TABLE‘;
=select * from user_tables;
2. 动态性能视图
select * from v$session;
select * from v$process;
练习:在SYS用户下查询DBA_OBJECTS,但是在scott用户下查不到的,授权查询给scott,使scott能够查询这个数据字典
SQL> conn scott/scott;
Connected.
SQL> select * from dba_objects;
select * from dba_objects
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> conn /as sysdba
Connected.
SQL> grant select on dba_objects to scott;
Grant succeeded.
本文出自 “冯宋林的博客” 博客,请务必保留此出处http://fengsonglin.blog.51cto.com/9860507/1615230
原文:http://fengsonglin.blog.51cto.com/9860507/1615230