表分析,识别大表
-- 查看最后的统计收集的时间
SELECT
table_name,
TO_CHAR(last_analyzed,'YYYY-MM-DD HH24:MI:SS') last_analyzed
FROM
dba_tables
WHERE
table_name = 'F_ORDER';
-- 收集统计信息
ANALYZE TABLE f_order COMPUTE STATISTICS;
-- 查看直方图的统计情况
SELECT
column_name,
histogram -- 是否有直方图
FROM
dba_tab_col_statistics
WHERE
table_name = 'F_ORDER';
-- 统计各个表的大小
SELECT
tabs.owner,
tabs.tablespace_name,
tabs.table_name,
round(
SUM(ext.bytes) / 1024 / 1024,
5
) m
FROM
sys.dba_tables tabs,
sys.dba_extents ext
WHERE
tabs.tablespace_name = ext.tablespace_name
AND
tabs.owner = upper('finance_dev')
GROUP BY
tabs.owner,
tabs.tablespace_name,
tabs.table_name;