我创建了一个这样的用户:
create user demouser identified by admin;
GRANT DBA to demouser;
我的问题是我想通过使用这个用户来获取表空间和使用百分比。
我创建了一个程序来获取此信息,但我只能将它作为 sys 作为 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","sys as sysdba 从 NetBeans 连接“,“行政”。