zoukankan      html  css  js  c++  java
  • 临时表空间

    临时表空间

    11g之前(不包括11g)临时表空间不会自动释放其内容,除非重启数据库;但11g之后可通过shrink方法来搜索临时表空间。

    临时表空间消耗的主要操作有:
    1.order by
    2.group by
    3.distinct
    4.union [all]
    5.create[|rebuild] index
    6.analyze

    1.查询数据库默认临时表空间
    select * from database_properties where property_name=upper('default_temp_tablespace');

    2.更改数据库默认临时表空间
    alter database default temporary tablespace temp;

    3.查询临时表空间的使用情况
    select  FILE_NAME
           ,TABLESPACE_NAME
           ,ROUND(BYTES/1024/1024/1024,2)||'G' BYTES
           ,AUTOEXTENSIBLE
           ,ROUND(MAXBYTES/1024/1024/1024,2)||'G' MAXBYTES
           ,INCREMENT_BY||'M' INCREMENT_BY
           ,ROUND(USER_BYTES/1024/1024/1024,2)||'G' USER_BYTES
    from dba_temp_files;
    select tablespace_name,tablespace_size,allocated_space,free_space from dba_temp_free_space;
    注:视图dba_temp_free_space的tablespace_size等于视图dba_temp_files的bytes;
    视图dba_temp_free_space的free_space等于视图dba_temp_files的bytes-user_bytes;
    视图dba_temp_free_space的allocated_space表示分配(next)出去的空间大小,它既包含不可用的空间部分,同样也包含可以的空间部分,因此它不一定等于free_space。

    4.创建临时表空间
    create temporary tablespace temp tempfile '/u02/oradata/orcl/temp01.dbf' size 10m autoextend on next 1m maxsize unlimitied;

    5.扩大临时表空间
    alter database tempfile '/u02/oradata/orcl/temp01.dbf' resize 500m;
    alter tablespace temp add tempfile '/u02/oradata/orcl/temp02.dbf' size 10m autoextend on next 1m maxsize unlimitied;

    6.删除临时表空间
    删除临时表空间的某个数据文件
    alter database tempfile '/u02/oradata/orcl/temp02.dbf' drop;
    删除临时表空间(彻底删除)
    drop tablespace temp including contents and datafiles;
    删除数据库默认的临时表空间:
    create temporary tablespace ...=>alter database default tablespace ...=>drop tablespace ...

    7.收缩临时表空间
    将临时表空间temp收缩为10m
    alter tablespace temp shrink space keep 10m;
    自动收缩临时表空间的某个数据文件到最小可能的大小
    alter tablespace temp shrink tempfile '/u02/oradata/orcl/temp01.dbf';

  • 相关阅读:
    从零开始入门 K8s | 有状态应用编排
    OAM 深入解读:OAM 为云原生应用带来哪些价值?
    你不得不了解 Helm 3 中的 5 个关键新特性
    CNCF 公布 2020 年 TOC 选举结果 | 云原生生态周报 Vol. 36
    调度系统设计精要
    Spring的IOC容器第一辑
    JavaScript工作体系中不可或缺的函数
    教你五步制作精美的HTML时钟
    web前端vertical-align的作用及对象详解
    JavaScript中常见的10个BUG及其修复方法
  • 原文地址:https://www.cnblogs.com/riskyer/p/3341911.html
Copyright © 2011-2022 走看看