我正在尝试使用以下 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
我错过了什么?