【问题标题】:Database Size in GB with use space and free space Oracle DB以 GB 为单位的数据库大小,包括使用空间和可用空间 Oracle DB
【发布时间】:2021-02-11 23:05:20
【问题描述】:

大家好,我正在尝试查找以 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

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

【问题讨论】:

    标签: oracle plsql database-administration


    【解决方案1】:

    错误消息指的是第 2 行的第 48 个字符。“减号”字符是 en-dash,而不是 hyphen/minus。你可以通过dumping the characters看到区别。

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

    重新输入字符,它应该可以工作。

    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"
    ...
    

    【讨论】:

    • 这给出了 oveall DWH 如何拆分每个模式的大小中断总大小与消耗大小是否可能?例如舞台、edw、mart...
    • @rakesh - 不是通过查看数据文件,但您可以查看 dba_segments 以获得架构使用的总空间。 This question 可能会有所帮助;首先我发现,可能还有很多其他的。
    • 我访问了您提供的参考网址,不幸的是我无法运行此查询 - 我无权访问此架构,我认为 SYSMAN.MGMT$METRIC_CURRENT ORA-00942: 表或视图可以不存在 00942. 00000 - “表或视图不存在” *原因:*操作:行错误:6 列:17
    • 是的,这是一个不好的例子,尽管我的回答中的一个查询是针对dba_segments,这应该可以。我没有重读while的东西。但是互联网上还有很多其他的答案和示例也展示了如何从dba_segments 获取数据。
    • 我已经写了一些问题,请您查看新帖子stackoverflow.com/questions/66170585/…
    猜你喜欢
    • 2016-09-06
    • 2016-02-10
    • 1970-01-01
    • 2014-12-26
    • 1970-01-01
    • 2013-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多