Oracle 临时表空间 temp表空间切换
一.TEMP表空间
临时表空间主要用途是在数据库进行排序运算、管理索引、访问视图等操作时提供临时的运算空间,当运算完成之后系统会自动清理。当oracle里需要用到sort的时候,PGA中sort_area_size大小不够时,将会把数据放入临时表空间里进行排序,同时如果有异常情况的话,也会被放入临时表空间,正常来说,在完成Select语句、create index等一些使用TEMP表空间的排序操作后,Oracle是会自动释放掉临时段的。注意这里的释放,仅仅是将这些空间标记为空闲,并可重用,真正占用的磁盘空间并没有释放。所以Temp表空间可能会越来越大。
排序是很耗资源的,Temp表空间满了,关键是优化你的语句,尽量使排序减少才是上策.
二、oracle temp表空间切换
查询temp表空间、创建temp2表空间5000m、切换临时表空间为 temp2、 删除临时表空间temp
oracle@xyy:/home/oracle> sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Fri Oct 11 14:18:44 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> SELECT temp_used.tablespace_name, total - used as "Free", total as "Total", round(nvl(total - used, 0) * 100 / total, 3) "Free percent"
2 FROM (SELECT tablespace_name, SUM(bytes_used)/1024/1024 used FROM GV$TEMP_SPACE_HEADER GROUP BY tablespace_name) temp_used,
3 (SELECT tablespace_name, SUM(bytes)/1024/1024 total FROM dba_temp_files GROUP BY tablespace_name) temp_total
4 WHERE temp_used.tablespace_name = temp_total.tablespace_name;
TABLESPACE_NAME Free Total Free percent
------------------------------ ---------- ---------- ------------
TEMP 0 29 0
SQL> create temporary tablespace temp2 tempfile '/home/oracle/ora11g/oradata/xyy/temp02.dbf' size 5000M autoextend off;
Tablespace created.
SQL> alter database default temporary tablespace temp2;
Database altered.
SQL> drop tablespace temp;
Tablespace dropped.
SQL> SELECT temp_used.tablespace_name, total - used as "Free", total as "Total", round(nvl(total - used, 0) * 100 / total, 3) "Free percent"
2 FROM (SELECT tablespace_name, SUM(bytes_used)/1024/1024 used FROM GV$TEMP_SPACE_HEADER GROUP BY tablespace_name) temp_used,
3 (SELECT tablespace_name, SUM(bytes)/1024/1024 total FROM dba_temp_files GROUP BY tablespace_name) temp_total
4 WHERE temp_used.tablespace_name = temp_total.tablespace_name;
TABLESPACE_NAME Free Total Free percent
------------------------------ ---------- ---------- ------------
TEMP2 4998 5000 99.96
temp表空间的 tempfile 为 temp01.dbf, 删除 temp01.dbf
oracle@xyy:/home/oracle/ora11g/oradata/xyy> ll
total 3297068
-rw-r----- 1 oracle oinstall 9748480 Oct 11 14:31 control01.ctl
-rw-r----- 1 oracle oinstall 9748480 Oct 11 14:31 control02.ctl
-rw-r----- 1 oracle oinstall 328343552 Oct 11 14:31 example01.dbf
-rw-r----- 1 oracle oinstall 536871424 Oct 11 14:31 redo01.log
-rw-r----- 1 oracle oinstall 536871424 Oct 11 14:31 redo02.log
-rw-r----- 1 oracle oinstall 536871424 Oct 11 14:31 redo03.log
-rw-r----- 1 oracle oinstall 566239232 Oct 11 14:31 sysaux01.dbf
-rw-r----- 1 oracle oinstall 744497152 Oct 11 14:31 system01.dbf
-rw-r----- 1 oracle oinstall 5242888192 Oct 11 14:29 temp01.dbf
-rw-r----- 1 oracle oinstall 5242888192 Oct 11 14:21 temp02.dbf
-rw-r----- 1 oracle oinstall 99622912 Oct 11 14:31 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Oct 11 14:31 users01.dbf
oracle@xyy:/home/oracle/ora11g/oradata/xyy>rm temp01.dbf
查询当前临时表空间
SQL> select username,temporary_tablespace from dba_users;
USERNAME TEMPORARY_TABLESPACE
------------------------------ ------------------------------
SYS TEMP2
SYSTEM TEMP2
OUTLN TEMP2
MGMT_VIEW TEMP2
FLOWS_FILES TEMP2
MDSYS TEMP2
ORDSYS TEMP2
EXFSYS TEMP2
DBSNMP TEMP2
WMSYS TEMP2
APPQOSSYS TEMP2
USERNAME TEMPORARY_TABLESPACE
------------------------------ ------------------------------
APEX_030200 TEMP2
OWBSYS_AUDIT TEMP2
ORDDATA TEMP2
CTXSYS TEMP2
ANONYMOUS TEMP2
SYSMAN TEMP2
XDB TEMP2
ORDPLUGINS TEMP2
OWBSYS TEMP2
SI_INFORMTN_SCHEMA TEMP2
OLAPSYS TEMP2
USERNAME TEMPORARY_TABLESPACE
------------------------------ ------------------------------
SCOTT TEMP2
ORACLE_OCM TEMP2
XS$NULL TEMP2
BI TEMP2
PM TEMP2
MDDATA TEMP2
IX TEMP2
SH TEMP2
DIP TEMP2
OE TEMP2
APEX_PUBLIC_USER TEMP2
USERNAME TEMPORARY_TABLESPACE
------------------------------ ------------------------------
HR TEMP2
SPATIAL_CSW_ADMIN_USR TEMP2
SPATIAL_WFS_ADMIN_USR TEMP2
36 rows selected.
创建临时表空间temp为5000m、切换临时表空间为temp表空间、查询数据库临时表空间使用、删除临时表空间temp2
SQL> create temporary tablespace temp tempfile '/home/oracle/ora11g/oradata/xyy/temp01.dbf' size 5000M autoextend off;
Tablespace created.
SQL> alter database default temporary tablespace temp;
Database altered.
SQL> select username,temporary_tablespace from dba_users;
USERNAME TEMPORARY_TABLESPACE
------------------------------ ------------------------------
SYS TEMP
SYSTEM TEMP
FLOWS_FILES TEMP
MDSYS TEMP
ORDSYS TEMP
EXFSYS TEMP
DBSNMP TEMP
SCOTT TEMP
WMSYS TEMP
ORACLE_OCM TEMP
APPQOSSYS TEMP
USERNAME TEMPORARY_TABLESPACE
------------------------------ ------------------------------
XS$NULL TEMP
APEX_030200 TEMP
OWBSYS_AUDIT TEMP
BI TEMP
PM TEMP
MDDATA TEMP
IX TEMP
ORDDATA TEMP
CTXSYS TEMP
ANONYMOUS TEMP
SH TEMP
USERNAME TEMPORARY_TABLESPACE
------------------------------ ------------------------------
OUTLN TEMP
DIP TEMP
OE TEMP
APEX_PUBLIC_USER TEMP
HR TEMP
SYSMAN TEMP
XDB TEMP
SPATIAL_CSW_ADMIN_USR TEMP
SPATIAL_WFS_ADMIN_USR TEMP
ORDPLUGINS TEMP
OWBSYS TEMP
USERNAME TEMPORARY_TABLESPACE
------------------------------ ------------------------------
MGMT_VIEW TEMP
SI_INFORMTN_SCHEMA TEMP
OLAPSYS TEMP
SQL> drop tablespace temp2;
Tablespace dropped.
oracle@xyy:/home/oracle/ora11g/oradata/xyy>ll
total 3297068
-rw-r----- 1 oracle oinstall 9748480 Oct 11 14:31 control01.ctl
-rw-r----- 1 oracle oinstall 9748480 Oct 11 14:31 control02.ctl
-rw-r----- 1 oracle oinstall 328343552 Oct 11 14:31 example01.dbf
-rw-r----- 1 oracle oinstall 536871424 Oct 11 14:31 redo01.log
-rw-r----- 1 oracle oinstall 536871424 Oct 11 14:31 redo02.log
-rw-r----- 1 oracle oinstall 536871424 Oct 11 14:31 redo03.log
-rw-r----- 1 oracle oinstall 566239232 Oct 11 14:31 sysaux01.dbf
-rw-r----- 1 oracle oinstall 744497152 Oct 11 14:31 system01.dbf
-rw-r----- 1 oracle oinstall 5242888192 Oct 11 14:29 temp01.dbf
-rw-r----- 1 oracle oinstall 5242888192 Oct 11 14:21 temp02.dbf
-rw-r----- 1 oracle oinstall 99622912 Oct 11 14:31 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Oct 11 14:31 users01.dbf
oracle@xyy:/home/oracle/ora11g/oradata/xyy>rm temp02.dbf
Oracle 临时表空间 temp表空间切换的更多相关文章
- 数据库实例: STOREBOOK > 表空间 > 编辑 表空间: TEMP
ylbtech-Oracle:数据库实例: STOREBOOK > 表空间 > 编辑 表空间: TEMP 表空间 > 编辑 表空间: TEMP 1. 一般信息返回顶部 1 ...
- Oracle Temp表空间切换
来源于: http://www.2cto.com/database/201507/418564.html 一.TEMP表空间作用 临时表空间主要用途是在数据库进行排序运算.管理索引.访问视图等操作时 ...
- Oracle Temp 表空间切换
一.TEMP表空间作用 暂时表空间主要用途是在数据库进行排序运算.管理索引.訪问视图等操作时提供暂时的运算空间,当运算完毕之后系统会自己主动清理.当 oracle 里须要用到 sort 的时候. PG ...
- 解决ora-01652无法通过128(在temp表空间中)扩展temp段的过程
解决ora-01652无法通过128(在temp表空间中)扩展temp段的过程 昨天开发人员跟我说,执行一个sql语句后,大约花了10分钟,好不容易有一个结果,但是报了一个ora-01652错误,查阅 ...
- Oracle数据库之创建表空间与用户
Oracle数据库之创建表空间与用户 一.创建表空间 基本语法表述: CREATE TABLESPACE tablespace_name [DATAFILE datafile_spec1 [,data ...
- 直接删除undo及temp表空间文件后的数据库恢复一例
前几天,某用户研发找到我,说他们的研发库坏了,问我能恢复不?我问他们做了什么操作,一个小男孩儿说,看到空间满了,清除了点儿数据,我说是不是连数据库的文件也清除了,他说没有,他清除的是ORACLE_HO ...
- Oracle数据库自带表空间的详细说明
1.SYSAUX表空间 SYSAUX表空间在Oracle Database 10g中引入,作为SYSTEM表空间的辅助表空间.以前一些使用独立表空间或系统表空间的数据库组件现在在SYSAUX表空间中创 ...
- Oracle数据库自带表空间
需求:需要整理现场用户创建的表空间以及其存储数据,进行规范化管理.在整理用户现场建立的表空间时,需要排除掉非用户创建的表空间,所有首先需要那些表空间是用户创建的,那些是Oracle自带的. 本机测试建 ...
- ora-01652无法通过128(在temp表空间中)扩展temp段
有两种错误:1.数据表空间不足 2.临时表空间不足 有两种原因:一是临时表空间空间太小,二是不能自动扩展. 分析过程: 既然是temp表空间有问题,那当然就要从temp表空间说起啦.首先要说明的 ...
随机推荐
- 只安装自己需要的Office2016组件的方法
转自:https://www.ithome.com/html/office/178814.htm http://www.orsoon.com/news/184524.html
- HDU 6162 Ch’s gift (树剖 + 离线线段树)
Ch’s gift Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total S ...
- 北邮校赛 F. Gabriel's Pocket Money(树状数组)
F. Gabriel's Pocket Money 2017- BUPT Collegiate Programming Contest - sync 时间限制 2000 ms 内存限制 65536 K ...
- 04、Unity_声音管理器
1.分享一个Unity中用于管理声音的声音管理器,适合于中小型项目,大项目就算了. 2.借鉴了很多的源码,最后修改完成,吸取百家之长,改为自己所用,哈哈. 3.源码奉上: /* * * 开发时间:20 ...
- ccpc秦皇岛部分题解
A. 题意:就是有一个大桌子,环绕有顺势站1~m共m个座位,n个选手坐在部分位置上.然后如果有一个人a了一道题,却没有立刻发气球给他,他产生怒气值是发气球给他的时间减去a题时间.现在有一个机器人顺时针 ...
- Codeforces 724E Goods transportation(最小割转DP)
[题目链接] http://codeforces.com/problemset/problem/724/E [题目大意] 每个城市有pi的物品可以运出去卖,si个物品可以买, 编号小的城市可以往编号大 ...
- [BalkanOI2016]Cruise
题目大意: 平面直角坐标系内有n个点,每个点有一个点权. 你从原点p出发,走若干个点然后回到原点. 两个点之间只能笔直走,你的收获为你的路径围起来的区域内的所有店权和除以路径长度. 问最大收益. 思路 ...
- MySQL v5.7.18 版本解压安装
下载MySQL https://dev.mysql.com/downloads/mysql/5.1.html#downloads 个人机子是64位的,所以选择下载:Windows (x86, 64-b ...
- 94.Txx考试
2894 Txx考试 时间限制: 1 s 空间限制: 32000 KB 题目等级 : 黄金 Gold 题解 查看运行结果 题目描述 Description Txx是一个成绩很差的人,考试便成了他 ...
- leetcode 576. Out of Boundary Paths
leetcode 576 题意大概就是在一个m*n的网格中,在坐标为[i,j]的网格上放一个物体,在规定时间N(t<=N)中,有多少种方法把物体移动出去.物体只能上下左右移动,一次移动一格,移动 ...