zoukankan      html  css  js  c++  java
  • ORACLE重设表空间的大小

    ORACLE重设表空间的大小
    You can enlarge a tablespace by:
    • Change the size of a data file:
    - Automatically during tablespace creation
    SQL> CREATE TABLESPACE userdata02
         DATAFILE '/u01/oradata/userdata02.dbf' SIZE 5M
         AUTOEXTEND ON NEXT 2M MAXSIZE 200M;

    - By specifying AUTOEXTEND after tablespace creation
    SQL> ALTER DATABASE
         DATAFILE '/u01/oradata/userdata02.dbf'
         AUTOEXTEND ON NEXT 2M;
        
    - Manually
    SQL> ALTER DATABASE
         DATAFILE '/u01/oradata/userdata02.dbf' RESIZE 5M;
        
    • Add a data file to a tablespace
    SQL> ALTER TABLESPACE userdata02
         ADD DATAFILE '/u01/oradata/userdata03.dbf' SIZE 5M;

    - 收缩表空间
    select a.file#,a.name,a.bytes/(1024*1024) CurrentMB,
           ceil(HWM * a.block_size)/(1024*1024) ResizeTo,
           (a.bytes - HWM * a.block_size)/(1024*1024) ReleaseMB,
           'alter database datafile '''||a.name||''' resize '||
           ceil(HWM * a.block_size/(1024*1024)) || 'M;' ResizeCMD
    from v$datafile a,
         (select file_id,max(block_id+blocks-1) HWM
           from dba_extents
           group by file_id) b
    where a.file# = b.file_id(+) and (a.bytes - HWM *block_size)>0
    order by 5
    - 针对特殊某个表空间的收缩
    select a.file#,a.name,a.bytes/(1024*1024) CurrentMB,
           ceil(HWM * a.block_size)/(1024*1024) ResizeTo,
           (a.bytes - HWM * a.block_size)/(1024*1024) ReleaseMB,
           'alter database datafile '''||a.name||''' resize '||
           ceil(HWM * a.block_size/(1024*1024)) || 'M;' ResizeCMD
    from v$datafile a,
         (select file_id,max(block_id+blocks-1) HWM
           from dba_extents c where exists 
                  (select 1 From v$tablespace d ,v$datafile e
                    where d.ts#=e.ts# and d.name='单独表空间名' and  e.file#=c.file_id)
           group by c.file_id) b
    where a.file# = b.file_id(+)
    and (a.bytes - HWM *block_size)>0
    order by 5

    李世侠,网名caibird2005 , initdba , 战神

    MySQL DBA经验6年;

    Oracle DBA经验10年;

    精通MySQL HA架构,复制,备份,恢复,SQL优化;

    熟悉SHELL编程、Python编程、SQL&PL/SQL编程;

    MySQL OCP课程讲师;

    ORACLE官方认证OCM证书;

    BLOG: http://www.cnblogs.com/caibird2005 

              http://www.initdba.cn 

    Wechat: caibird2005 

    TEL :+86-186-5881-5300 +86-180-7290-8651 

  • 相关阅读:
    统计元音 题解
    C语言合法标识符 题解
    查找最大元素 题解
    java_day05_数组
    java_day4_while循环
    java_day03_if,Switch,三目和for循环
    java_day02_基本运算符和数据类型
    java_day01_注释,变量
    前端_day04_行,块,RGB,行高,overflow
    前端_day03_盒子模型,border,padding,margin
  • 原文地址:https://www.cnblogs.com/caibird2005/p/1405615.html
Copyright © 2011-2022 走看看