|
Notice: This blog is written by Bo Tang.
- select * from dba_tablespaces;
- select t.table_name, t.tablespace_name
- from dba_tables t where t.table_name like 'T0%';
-
- select * from database_properties;
- select * from dba_role_privs rp where rp.grantee='HR';
-
- select * from dba_sys_privs sp where sp.grantee='HR';
-
复制代码- select * from dba_segments s
- where s.segment_name='T05207_A';
复制代码
- select * from dba_extents e where e.owner='HR' and e.segment_name='T05207_A';
复制代码
380090里头放的是4个比特的位图(9iR1之前放的是free-list)
- select t.segment_space_management from dba_tablespaces t where t.tablespace_name='USERS';
复制代码
- select t.tablespace_name, t.segment_space_management from dba_tablespaces t
- where t.tablespace_name in ( 'SYSTEM','UNDOTBS1' ,'TEMP', 'SYSAUX');
复制代码
pct_used(人为指定40%)
- create tablespace tbs2 datafile size 10M segment space management manual;
复制代码- select t.tablespace_name, t.segment_space_management from dba_tablespaces t
- where t.tablespace_name in ( 'TBS2', 'TBS1');
复制代码
- select t.table_name, t.pct_free, t.pct_used, t.ini_trans
- from dba_tables t where t.owner='HR' and t.table_name in ('T05207_B', 'T05207_C');
复制代码
- SQL> alter table t05207_b pctfree 20 pctused 50 ;
- Table altered.
- SQL> alter table t05207_c pctfree 20 pctused 50;
- Table altered.
复制代码
得出推论:关注pct_free和ini_trans会跟调优有密切关系。调整块里头的行密度:
- SQL> create table t05207_d( a char(200)) ;
- Table created.
- SQL> begin
- 2 for i in 1..1000
- 3 loop
- 4 insert into t05207_d values(to_char(i));
- 5 end loop;
- 6 commit;
- 7 end;
- 8 /
- PL/SQL procedure successfully completed.
复制代码- select s.bytes/1024/1024 bytesM, s.blocks
- from dba_segments s where s.owner='HR' and s.segment_name='T05207_D';
复制代码
- alter table hr.t05207_d pctfree 80;
-
- alter table hr.t05207_d move tablespace users;
-
复制代码-
- select s.bytes/1024/1024 bytesM, s.blocks, s.tablespace_name
- from dba_segments s where s.owner='HR' and s.segment_name='T05207_D';
-
复制代码
索引是没有pct_used概念的,索引的initrans应该是对应表的两倍。
- select i.index_name,
- i.ini_trans,
- i.pct_free
- from dba_indexes i where i.owner='HR' and i.table_name in ('T05207_B' ,'T05207_C');
复制代码
- select * from dba_segments s where s.owner='HR' and s.segment_name='TBIG';
- select * from dba_extents e where e.owner='HR' and e.segment_name='TBIG';
- create tablespace tbs3 datafile '/u01/app/oracle/oradata/orcl/tbs3_a.dbf'size 10M ,
- '/u01/app/oracle/oradata/orcl/tbs3_b.dbf' size 10M uniform size 1M ;
-
- create tablespace tbs4 datafile size 5M blocksize 4096;
- create bigfile tablespace tbs5 datafile size 5M autoextend on maxsize 4T;
- alter tablespace tbs4 add datafile size 5M ;
- alter tablespace tbs5 add datafile size 5M;
复制代码
查看用量:
- select sum(bytes)/1024/1024 from dba_data_files df
- where df.tablespace_name='SYSTEM';
-
- --346.25
- --800
- select sum(bytes)/1024/1024 from dba_free_space fs
- where fs.tablespace_name='SYSTEM';
-
- --36.0625
- --27.5625
- select 800-27.5625 from dual;
- select sum(bytes)/1024/1024 from dba_data_files df
- where df.tablespace_name='UNDOTBS1'
- ;
-
- --115
- select sum(e.bytes)/1024/1024
- from dba_undo_extents e
- where e.tablespace_name='UNDOTBS1' and e.status <> 'EXPIRED';
-
- select sum(bytes)/1024/1024 from dba_temp_files tf
- where tf.tablespace_name='TEMP'
- ;
-
- --627
-
- select tfs.free_space/1024/1024
-
- from dba_temp_free_space tfs
- where tfs.tablespace_name='TEMP';
- --626
复制代码
|
|