以普通用户身份获取表空间和百分比值

时间:2013-08-20 20:51:14

标签: sql oracle plsql

我创建了一个这样的用户:

create user demouser identified by admin; 
GRANT DBA to demouser; 

我的问题是我希望通过使用此用户来获取表空间和使用百分比。

我创建了一个获取此信息的过程,但我可以像sysdba一样运行它:

CREATE OR REPLACE PACKAGE E_Types as
PROCEDURE TestProc (p_recordset OUT SYS_REFCURSOR); END E_Types; 
/ CREATE OR REPLACE PACKAGE BODY E_Types IS
PROCEDURE TestProc (p_recordset OUT SYS_REFCURSOR) IS 
BEGIN 
  OPEN p_recordset 
  FOR 
     select a.TABLESPACE_NAME as Tablespace,round((1-((a.BYTES-nvl(b.BYTES,0))/a.BYTES))*100,2) AS Percentages 
     from 
     (
        select TABLESPACE_NAME, sum(BYTES) BYTES 
        from sys.dba_data_files 
        group by TABLESPACE_NAME
     ) a, 
     (
        select TABLESPACE_NAME, sum(BYTES) BYTES 
        from sys.dba_free_space 
        group by TABLESPACE_NAME
     ) b 
     where a.TABLESPACE_NAME = b.TABLESPACE_NAME (+) 
     order by ((a.BYTES-b.BYTES)/a.BYTES) desc; 
 END; 
END; /

我想使用“jdbc:oracle:thin:@localhost:1521:XE”,“DEMOUSER”,“admin”而不是“jdbc:oracle:thin:@localhost:1521:XE”从NetBeans连接,“ sys as sysdba“,”admin“。

0 个答案:

没有答案