在 Oracle 数据库(新模式)中创建新用户时,需要验证现有表空间的可用性。此查询将向您显示那里有什么以及有多少空间可以免费使用。
SELECT df.tablespace_name "Tablespace",
totalusedspace "Used MB",
(df.totalspace - tu.totalusedspace) "Free MB",
df.totalspace "Total MB",
ROUND(100 * ( (df.totalspace - tu.totalusedspace)/ df.totalspace)) "% Free"
FROM
(SELECT tablespace_name,
ROUND(SUM(bytes) / 1048576) TotalSpace
FROM dba_data_files
GROUP BY tablespace_name
) df,
(SELECT ROUND(SUM(bytes)/(1024*1024)) totalusedspace,
tablespace_name
FROM dba_segments
GROUP BY tablespace_name
) tu
WHERE df.tablespace_name = tu.tablespace_name;
此外,此查询将显示表空间文件所在的位置:
SELECT df.tablespace_name "Tablespace",
totalusedspace "Used MB",
(df.totalspace - tu.totalusedspace) "Free MB",
df.totalspace "Total MB",
ROUND(100 * ( (df.totalspace - tu.totalusedspace)/ df.totalspace)) "% Free"
FROM
(SELECT tablespace_name,
ROUND(SUM(bytes) / 1048576) TotalSpace
FROM dba_data_files
GROUP BY tablespace_name
) df,
(SELECT ROUND(SUM(bytes)/(1024*1024)) totalusedspace,
tablespace_name
FROM dba_segments
GROUP BY tablespace_name
) tu
WHERE df.tablespace_name = tu.tablespace_name;
以下是有关 Oracle 如何管理用户、模式和表空间的一些参考资料。
https://community.oracle.com/message/1832920 http://docs.oracle.com/cd/B28359_01/server.111/b28310/tspaces014.htm#ADMIN11412
http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_8003.htm
http://stackoverflow.com/questions/880230/difference-between-a-user-and-a-schema-in-oracle
https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6162110256950