使用 space 和免费 space Oracle DB 的数据库大小(以 GB 为单位)

Database Size in GB with use space and free space Oracle DB

大家好,我正在尝试使用已用 space 和免费 space

查找以 GB 为单位的数据库大小

查询

select round(sum(used.bytes) / 1024 / 1024 / 1024 ) || 'GB' "Database Size"
, round(sum(used.bytes) / 1024 / 1024 / 1024 ) –
round(free.p / 1024 / 1024 / 1024) || 'GB' "Used space"
, round(free.p / 1024 / 1024 / 1024) || 'GB' "Free space"
from (select bytes
from v$datafile
union all
select bytes
from v$tempfile
union all
select bytes
from v$log) used
, (select sum(bytes) as p
from dba_free_space) free
group by free.p
/

错误

ORA-00911: invalid character
00911. 00000 -  "invalid character"
*Cause:    identifiers may not start with any ASCII character other than
           letters and numbers.  $#_ are also allowed after the first
           character.  Identifiers enclosed by doublequotes may contain
           any character other than a doublequote.  Alternative quotes
           (q'#...#') cannot use spaces, tabs, or carriage returns as
           delimiters.  For all other contexts, consult the SQL Language
           Reference Manual.
*Action:
Error at Line: 2 Column: 48

尝试后仍无法纠正错误,有什么建议吗?

错误消息指的是第 2 行的第 48 个字符。'minus' 字符是一个 en-dash, not a hyphen/minus. You can see the difference by dumping the characters

您的类型可能是意外的,或者可能是从 Word 文档中复制和粘贴的。这也会导致 'smart' 引号出现问题,有时甚至会导致不间断空格。

重新输入字符,应该可以了。

select round(sum(used.bytes) / 1024 / 1024 / 1024 ) || 'GB' "Database Size"
, round(sum(used.bytes) / 1024 / 1024 / 1024 ) -
round(free.p / 1024 / 1024 / 1024) || 'GB' "Used space"
...