如何为用户获取表空间中的可用空间(Oracle)

Emr*_*rah 9 oracle10g tablespace

我正在开发一个Web应用程序,我需要警告用户他们在给定的db用户的表空间中空间不足.应用程序不知道db的系统用户的凭据,因此我无法查询dba_users,dba_free_space..etc等视图.

我的问题是,Oracle是否有办法让用户在他们的表空间中找出剩余多少空间?

谢谢!

Emr*_*rah 19

请原谅我对这个问题的无知,因为我认为只有数据存储的可用视图是dba_free_space等.

我意识到对于已登录的用户,它们有user_free_space ..视图.这里提到的查询的修改版本将是我的问题的答案.

查询如下:(获取记录用户的DEFAULT_TABLESPACE上的空格)

SELECT
  ts.tablespace_name,
  TO_CHAR(SUM(NVL(fs.bytes,0))/1024/1024, '99,999,990.99') AS MB_FREE
FROM
  user_free_space fs,
  user_tablespaces ts,
  user_users us
WHERE
  fs.tablespace_name(+)   = ts.tablespace_name
AND ts.tablespace_name(+) = us.default_tablespace
GROUP BY
  ts.tablespace_name;
Run Code Online (Sandbox Code Playgroud)

它将以MB为单位返回可用空间