本次实验测试,oracle数据库视图中v$,v_$,gv$之间的关系
总结:
v_$是动态性能视图,通过sql查询数据库基表返回记录。例如,v_$database对象是视图类型,可对其它用户授权访问;
v$database则是为了简化查询,是v_$database的同义词,oracle同义词无法作为对象,进行赋权语句执行grant;
gv_则是集群,多了一个Inst_id区分实例
1.对象类型
1 SYS@ceshi>select object_name,object_type,status from user_objects where object_name in('V$SESSION', 2 11:02:55 2 'V_$SESSION','GV$SESSION'); 3 4 OBJECT_NAME OBJECT_TYPE STATUS 5 ------------------------------ ------------------- ------- 6 V_$SESSION VIEW VALID 7 8 SYS@ceshi>select synonym_name,table_name from dba_synonyms where synonym_name in('V$SESSION','GV$SESSION'); 9 10 SYNONYM_NAME TABLE_NAME 11 ------------------------------ ------------------------------ 12 GV$SESSION GV_$SESSION 13 V$SESSION V_$SESSION
2.授权报错
1 11:08:46 SYS@ceshi>grant select on V_$SESSION to scott; 2 3 Grant succeeded. 4 5 Elapsed: 00:00:00.13 6 11:09:19 SYS@ceshi>grant select on V$SESSION to scott; 7 grant select on V$SESSION to scott 8 * 9 ERROR at line 1: 10 ORA-02030: can only select from fixed tables/views
授权,需要授予对象权限,同义词无法作为授权对象
3.GET_DDL
提取GV$SESSION基表定义,如下链接可以帮助查询,普通get_ddl查询的定义是错误的
http://t.askmaclean.com/thread-392-1-1.html