--�ռ���ͳ����Ϣ
exec dbms_stats.gather_table_stats(ownname=>'SCHEMA_NAME',tabname=> 'TABLE_NAME');
-- ȷ����Ƭ�̶�
SELECT table_name,
ROUND ( (blocks * 8), 2) "��ˮλ�ռ� k",
ROUND ( (num_rows * avg_row_len / 1024), 2) "��ʵʹ�ÿռ� k",
ROUND ( (blocks * 10 / 100) * 8, 2) "Ԥ���ռ�(pctfree) k",
ROUND (
( blocks * 8
- (num_rows * avg_row_len / 1024)
- blocks * 8 * 10 / 100),
2)
"�˷ѿռ� k"
FROM user_tables
WHERE temporary = 'N'
ORDER BY 5 DESC;
--�鿴���ϴ��ռ�ͳ����Ϣʱ��
select table_name,last_analyzed from dba_tables where owner = 'SCOTT';
--�ռ����� Schema �ж����ͳ����Ϣ
exec dbms_stats.gather_schema_stats(ownname=>'SCOTT');
--���ͱ�ĸ�ˮλ��
select 'alter table '||TABLE_NAME||' move tablespace '||TABLESPACE_NAME||';' from user_tables where table_name='EMP';
--�ؽ����ϵ�����
select 'alter index '||index_name||' rebuild online;' from user_indexes where table_name='EMP';
--�ռ����ϵ�ͳ����Ϣ
select 'analyze table '||TABLE_NAME||' compute statistics;' from user_tables where table_name='EMP';
--�ռ������ϵ�ͳ����Ϣ
select 'analyze index '||index_name||' compute statistics;' from user_indexes where table_name='EMP';
--�������Ӱ��DML����
alter table TABLE_NAME enable ROW MOVEMENT;--�������ƶ�����
alter table TABLE_NAME shrink space compact; --ֻ������Ƭ �����տռ�
alter table TABLE_NAME shrink space; --������Ƭ�����տռ䣬������ˮλ�ߡ�ҵ����ʱִ��
alter table TABLE_NAME disable ROW MOVEMENT;--�ر����ƶ�
--һ����θ
alter table TABLE_NAME shrink space;
评论