我正在尝试使用以下SQL查询数据库:
select round(b.Used_space*100/a.tablespace_size,2)
from
(select tablespace_name,sum(bytes/1024/1024/1024) tablespace_size, sum(decode(MAXBYTES,0,bytes/1024/1024/1024,MAXBYTES/1024/1024/1024)) max_tablespace_size
from dba_temp_files group by tablespace_name) a,
(select x.TABLESPACE tablespace_name,sum(x.blocks*y.block_size/1024/1024/1024) used_space from v$sort_usage x , dba_tablespaces y where x.tablespace=y.tablespace_name group by x.TABLESPACE) b
where a.tablespace_name=b.tablespace_name (+);
在oracle中运行时,它运行正常。当我尝试从java执行查询时,我得到“坏sql语法”。
org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [select a.tablespace_name,a.tablespace_size Allocated_space_IN_GB, round(b.Used_space,2) Used_Space_in_GB, round(b.Used_space*100/a.tablespace_size,2) "Used%", a.max_tablespace_size MAX_tablespace_size_IN_GB ,round(b.used_space*100/a.max_tablespace_size,2) "Max_Alloc_Used%" from (select tablespace_name,sum(bytes/1024/1024/1024) tablespace_size, sum(decode(MAXBYTES,0,bytes/1024/1024/1024,MAXBYTES/1024/1024/1024)) max_tablespace_size from dba_temp_files group by tablespace_name) a, (select x.TABLESPACE tablespace_name,sum(x.blocks*y.block_size/1024/1024/1024) used_space from v$sort_usage x , dba_tablespaces y where x.tablespace=y.tablespace_name group by x.TABLESPACE) b where a.tablespace_name=b.tablespace_name (+)]; nested exception is java.sql.SQLException: ORA-00942: table or view does not exist
Caused by: java.sql.SQLException: ORA-00942: table or view does not exist
我缺少什么?
答案 0 :(得分:0)
运行java时使用的oracle登录似乎可能与在oracle中运行查询时使用的oracle登录不同。如果是这种情况,那么其中一个可能就是答案:
根据你正在使用的表格(dba_temp_blah),我怀疑1是anser。