新手警报:如何确定我在 Oracle 11g 数据库中使用了多少存储空间?

Newbie Alert: How Do I Determine How Much Storage I'm Using in an Oracle 11g Database?

技术人员--

我正在将 Oracle 11g 数据库迁移到 MS SQL Server 2012 实例。在我开始从 11g 到 MSSQL 的实际数据物理副本之前,我如何确定我需要预留哪种 space?在 Oracle SQL Developer 中,我能够在 SQL 会话中找到“统计信息”选项卡。我看到此选项卡可能会为我提供我正在寻找的一些 high-level/rough 想法版本——但是,我有数百个表,因此这种方法似乎不切实际。有没有办法发出 sql 语句,或执行现有的存储过程来确定需要多少物理 space 来包含此数据?

我手头上的一些查询对本练习很有用

找出 tablespace 和他们使用的 space

col "Tablespace" for a22
col "Used MB" for 99,999,999
col "Free MB" for 99,999,999
col "Total MB" for 99,999,999

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))
"Pct. 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 ;

在 tablespace

内从 table 获取存储空间
COLUMN TABLE_NAME FORMAT A20
COLUMN TABLESPACE_NAME FORMAT A20

SELECT
SUBSTR(s.segment_name,1,20) TABLE_NAME,
SUBSTR(s.tablespace_name,1,20) TABLESPACE_NAME,
ROUND(DECODE(s.extents, 1, s.initial_extent,
(s.initial_extent + (s.extents-1) * s.next_extent))/1024000,2) ALLOCATED_MB,
ROUND((t.num_rows * t.avg_row_len / 1024000),2) REQUIRED_MB
FROM
dba_segments s,
dba_tables t
WHERE
s.owner = t.owner AND
s.segment_name = t.table_name and
s.tablespace_name = '<yourtablespacename>'
ORDER BY 3 ASC;