Bo's Oracle Station

查看: 1754|回复: 0

课程第13次

[复制链接]

27

主题

27

帖子

183

积分

超级版主

Rank: 8Rank: 8

积分
183
发表于 2019-10-21 20:44:57 | 显示全部楼层 |阅读模式
Notice: This blog is written by Bo Tang.

  1. select  * from dba_tablespaces;

  2. select  t.table_name, t.tablespace_name
  3. from dba_tables t where t.table_name like 'T0%';

  4. select * from database_properties;

  5. select  * from dba_role_privs  rp where rp.grantee='HR';

  6. select * from dba_sys_privs sp where sp.grantee='HR';

复制代码
  1. select  * from dba_segments  s
  2. where s.segment_name='T05207_A';
复制代码




qqq.png




  1. select * from dba_extents e where e.owner='HR' and e.segment_name='T05207_A';
复制代码
AAA.png

380090里头放的是4个比特的位图(9iR1之前放的是free-list)

  1. select  t.segment_space_management from dba_tablespaces t where t.tablespace_name='USERS';
复制代码
1111.png

  1. select t.tablespace_name, t.segment_space_management from dba_tablespaces t
  2. where t.tablespace_name in ( 'SYSTEM','UNDOTBS1' ,'TEMP', 'SYSAUX');

复制代码
111.png

pct_used(人为指定40%)

  1. create tablespace tbs2 datafile  size 10M segment space management manual;
复制代码
  1. select t.tablespace_name, t.segment_space_management from dba_tablespaces t
  2. where t.tablespace_name in ( 'TBS2', 'TBS1');
复制代码
000.png

  1. select  t.table_name, t.pct_free, t.pct_used, t.ini_trans
  2.   from dba_tables t where t.owner='HR' and t.table_name  in ('T05207_B', 'T05207_C');
复制代码

000.png

  1. SQL>  alter table t05207_b pctfree 20 pctused 50 ;

  2. Table altered.

  3. SQL> alter table t05207_c pctfree 20 pctused 50;

  4. Table altered.
复制代码

000.png

得出推论:关注pct_free和ini_trans会跟调优有密切关系。调整块里头的行密度:

  1. SQL> create table t05207_d( a char(200)) ;

  2. Table created.

  3. SQL> begin
  4.   2   for i in 1..1000
  5.   3   loop
  6.   4    insert into t05207_d values(to_char(i));
  7.   5   end loop;
  8.   6   commit;
  9.   7  end;
  10.   8  /

  11. PL/SQL procedure successfully completed.
复制代码
  1. select  s.bytes/1024/1024 bytesM, s.blocks
  2. from dba_segments s where s.owner='HR' and s.segment_name='T05207_D';
复制代码

000.png

  1. alter table hr.t05207_d pctfree 80;

  2. alter table hr.t05207_d move tablespace users;
复制代码
  1.   
  2. select  s.bytes/1024/1024 bytesM, s.blocks, s.tablespace_name
  3. from dba_segments s where s.owner='HR' and s.segment_name='T05207_D';
复制代码

000.png

索引是没有pct_used概念的,索引的initrans应该是对应表的两倍。

  1. select  i.index_name,
  2.          i.ini_trans,
  3.          i.pct_free      
  4.   from dba_indexes i where i.owner='HR' and i.table_name in ('T05207_B' ,'T05207_C');
复制代码

000.png


  1. select  * from  dba_segments s where s.owner='HR' and s.segment_name='TBIG';

  2. select * from dba_extents e where e.owner='HR' and e.segment_name='TBIG';


  3. create tablespace tbs3 datafile  '/u01/app/oracle/oradata/orcl/tbs3_a.dbf'size 10M ,
  4.                      '/u01/app/oracle/oradata/orcl/tbs3_b.dbf' size 10M  uniform size 1M ;
  5.                      
  6. create tablespace tbs4 datafile size 5M blocksize 4096;


  7. create bigfile tablespace tbs5 datafile size 5M autoextend on maxsize 4T;  

  8. alter tablespace tbs4 add datafile size 5M ;

  9. alter tablespace tbs5 add  datafile size 5M;
复制代码

查看用量:
  1. select  sum(bytes)/1024/1024 from dba_data_files df
  2. where df.tablespace_name='SYSTEM';

  3. --346.25
  4. --800

  5. select  sum(bytes)/1024/1024 from dba_free_space fs
  6. where fs.tablespace_name='SYSTEM';

  7. --36.0625
  8. --27.5625


  9. select  800-27.5625   from dual;

  10. select  sum(bytes)/1024/1024 from dba_data_files df
  11. where df.tablespace_name='UNDOTBS1'
  12. ;

  13. --115

  14. select sum(e.bytes)/1024/1024
  15. from dba_undo_extents e
  16. where e.tablespace_name='UNDOTBS1'  and e.status <> 'EXPIRED';

  17. select  sum(bytes)/1024/1024 from dba_temp_files tf
  18. where tf.tablespace_name='TEMP'
  19. ;

  20. --627

  21. select  tfs.free_space/1024/1024

  22.    from dba_temp_free_space  tfs
  23.     where tfs.tablespace_name='TEMP';
  24. --626
复制代码
000.png



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-5-20 02:45 , Processed in 0.040931 second(s), 27 queries .

快速回复 返回顶部 返回列表