Bo's Oracle Station

查看: 2695|回复: 0

课程第51次(2017-11-07星期二)表空间

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2017-11-7 20:51:02 | 显示全部楼层 |阅读模式
1Z0-052第7章
1Z0-05219章(上完14章),1Z0-05321章(上完16章)和1Z0-063多租户部分共9章(上完0章)
总共上完全部49章中的30
Screenshot-1.png


Screenshot.png

  1. CREATE SMALLFILE TABLESPACE "TBS1"
  2. DATAFILE '/u01/app/oracle/oradata/orcl/tbs1.dbf' SIZE 5M AUTOEXTEND ON
  3.   NEXT 2M MAXSIZE 2G LOGGING
  4.    EXTENT MANAGEMENT DICTIONARY
  5.   DEFAULT STORAGE
  6.   ( INITIAL 512K NEXT 512K MINEXTENTS 1 MAXEXTENTS UNLIMITED
  7.   PCTINCREASE 0) MINIMUM EXTENT 512K;
  8.   
  9.   
  10.   -----
  11.   select * from dba_tablespaces;
  12.   
  13.    ----
  14.    
  15.    select  * from dba_extents e
  16.     where e.OWNER='HR' and e.SEGMENT_NAME='T04209_UNAME';
  17.   
  18.   create table hr.t05207_a ( a  number )
  19.   STORAGE
  20.   ( INITIAL 512K NEXT 512K MINEXTENTS 1 MAXEXTENTS UNLIMITED
  21.   PCTINCREASE 0);
  22.   
  23.   select  * from dba_extents e
  24.    where e.OWNER='HR' and e.SEGMENT_NAME='T05207_A';
  25.    
  26.    insert into hr.t05207_a  values (1);
  27.    
  28.    

  29.    
  30.      select  * from dba_extents e
  31.    where e.OWNER='HR' and e.SEGMENT_NAME='T05207_A';
  32.    
  33.       create tablespace tbs2 datafile '/u01/app/oracle/oradata/orcl/tbs2.dbf' size 5M
  34.     autoextend on next 2M maxsize 2G
  35.     uniform size 512K;
  36.         
  37.         create table hr.t05207_b ( a  number )
  38.          tablespace tbs2;
  39.         insert into hr.t05207_b  values (1);
  40.         
  41.         commit;
  42.         
  43.            select  * from dba_extents e
  44.    where e.OWNER='HR' and e.SEGMENT_NAME='T05207_B';
  45.    
  46.    ----
  47.    
复制代码
存储用量:
  1. select  sum(bytes)/1024/1024  from  dba_free_space  
  2. where tablespace_name='SYSTEM';

  3. select  sum(bytes)/1024/1024  from  dba_data_files
  4. where tablespace_name='SYSTEM';

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

  7. select  sum(bytes)/1024/1024  from  dba_data_files
  8. where tablespace_name='EXAMPLE';

  9. /*error

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

  13. select  sum(bytes)/1024/1024
  14.    from dba_undo_extents ue
  15.     where ue.STATUS<> 'EXPIRED' and ue.TABLESPACE_NAME='UNDOTBS1';
  16.   
  17. select  sum(bytes)/1024/1024  from  dba_data_files
  18. where tablespace_name='UNDOTBS1';

  19.   /*error

  20.   select  sum(bytes)/1024/1024  from  dba_free_space  
  21. where tablespace_name='TEMP';
  22. */

  23. select  sum(ep.BYTES_CACHED) /1024/1024 , sum(ep.BYTES_USED)/1024/1024
  24.   from v$temp_extent_pool ep
  25.   where ep.TABLESPACE_NAME='TEMP';

  26.   select  sum(bytes)/1024/1024  from  dba_temp_files
  27. where tablespace_name='TEMP';
复制代码

Screenshot-2.png

Screenshot-3.png

关于PCT_USED:
Screenshot-4.png

关于bigfile tablespace:


  1. select  t.TABLESPACE_NAME ,t.SEGMENT_SPACE_MANAGEMENT
  2.   from dba_tablespaces t ;
  3.   
  4. create tablespace tbs3 datafile '/u01/app/oracle/oradata/orcl/tbs3.dbf'
  5. size 5M segment space management manual;

  6. select  t.TABLESPACE_NAME ,t.SEGMENT_SPACE_MANAGEMENT
  7.   from dba_tablespaces t ;
  8.   
  9.   create table hr.t05207_c ( a  number )  tablespace users;
  10.   
  11.   create table hr.t05207_d( a number ) tablespace tbs3;
  12.   
  13.   
  14.   select  * from dba_tables t
  15.    where t.TABLE_NAME   like 'T05207_%';
  16.    
  17.    
  18.    create table hr.t05207_e ( a  number )  tablespace users
  19.       pctfree 20 pctused 50 initrans 2  ;

  20. alter database datafile '/u01/app/oracle/oradata/orcl/tbs3.dbf' resize 20M ;

  21. alter tablespace tbs3 add datafile '/u01/app/oracle/oradata/orcl/tbs3b.dbf' size 20M ;

  22. create bigfile tablespace tbs4 datafile '/u01/app/oracle/oradata/orcl/tbs4.dbf' size 20M autoextend on
  23. maxsize 4T;
复制代码


Screenshot-5.png
Screenshot-6.png
回复

使用道具 举报

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

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-4-19 01:59 , Processed in 0.045117 second(s), 27 queries .

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