oracle

推荐列表 站点导航

当前位置:首页 > 数据库 > oracle >

oracle表空单清理常用代码段整理

来源:网络整理  作者:  发布时间:2020-12-14 01:45
清理TEMP临时表空间、清理UNDO表空间、清理TEMPTABS表空间等等,有类似需求的朋友可以参考下哈...
group by tablespace_name

复制代码 代码如下:

select 'drop table '||segment_name ||';' from dba_segments where tablespace_name='TEMPTABS' and segment_name like 'TT%' and segment_name not like '%_FILE';
#将系统UNDO表空间指向undotbs2


SQL>SELECT
group by tablespace_name


, ( select tablespace_name, sum(bytes_cached) bytes
#确保所有在UNDOTBS1的undo segment都已offline
#删除临时表空间temp02


[code]
, NVL(s.current_users, 0) current_users
AND d.tablespace_name = t.tablespace_name(+)
sqlplus '/as sysdba'


#创建TEMPTABS表空间
#重启数据库
SQL>@q_tbsFREE

FROM
AND d.extent_management like 'LOCAL'
, ( select tablespace_name, sum(bytes) bytes
, NVL(a.bytes, 0) tablespace_size
1.查询表空间使用情况:
#将系统UNDO表空间指回undotbs1
或者删除表


WHERE

复制代码 代码如下:

sqlplus system/manager@topprod

SQL>drop tablespace undotbs2 including contents and datafiles;

复制代码 代码如下:

#删除原来的临时表空间temp
from dba_temp_files
SQL>alter system set undo_tablespace=undotbs2 scope=both;
#创建一个UNDO表空间undotbs2,用作临时替换
SQL>startup
) t

SQL>create tablespace temptabs datafile '/u2/oradb/oradata/topprod/temptabs.dbf' size 4096M autoextend on next 100M;
SQL>drop tablespace temptabs including contents and datafiles;
sqlplus system/manager@topprod
3.清理UNDO表空间:(在无用户连接的状况下操作,最好在清理之前重启一下数据库)
SQL>drop tablespace temp including contents and datafiles;
) a
d.tablespace_name tablespace_name
, v$sort_segment s
, d.status tablespace_status
AND d.contents like 'TEMPORARY';
SQL>drop tablespace undotbs1 including contents and datafiles;
#创建一个临时表空间temp02,用作临时替换
4.增加系统表空间:
AND d.tablespace_name = s.tablespace_name(+)
SQL>alter system set undo_tablespace=undotbs1 scope=both;


SQL>drop tablespace temp02 including contents and datafiles;

#创建新的临时表空间temp
#删除TEMPTABS表空间

复制代码 代码如下:

SQL>alter database default temporary tablespace temp02;
from v$temp_extent_pool
#将系统临时表空间指回temp
#删除UNDO表空间undotbs2
sys.dba_tablespaces d
2.清理TEMP临时表空间:(在无用户连接的状况下操作,最好在清理之前重启一下数据库)
3.清理TEMPTABS表空间:
SQL>shutdown immediate
sqlplus '/as sysdba'
SQL>create undo tablespace undotbs1 datafile '/u2/oradb/oradata/topprod/undotbs01.dbf' size 4096M;
#删除原来的UNDO表空间undotbs1
d.tablespace_name = a.tablespace_name(+)

复制代码 代码如下:

SQL>create temporary tablespace temp tempfile '/u2/oradb/oradata/topprod/temp01.dbf' size 4096M autoextend on next 100M;

, TRUNC(NVL(t.bytes / a.bytes * 100, 0)) used_pct
SQL>alter database default temporary tablespace temp;
, NVL(t.bytes, 0) used
#创建新的临时表空间undotbs1
SQL> select SEGMENT_NAME ,STATUS ,TABLESPACE_NAME from dba_rollback_segs;
SQL>startup
#将系统临时表空间指向temp02
#重启数据库
SQL>create undo tablespace undotbs2 datafile '/u2/oradb/oradata/topprod/undotbs02.dbf' size 10M autoextend on next 10M;
SQL>create temporary tablespace temp02 tempfile '/u2/oradb/oradata/topprod/temp02.dbf' size 10M autoextend on next 10M;
alter tablespace SYSTEM add datafile '/u2/oradb/oradata/topprod/system02.dbf' size 2000M autoextend on next 10M;

复制代码 代码如下:

2.查询temp使用方法:
SQL>shutdown immediate

alter tablespace SYSAUX add datafile '/u2/oradb/oradata/topprod/sysaux02.dbf' size 2000M autoextend on next 10M;

相关热词: oracle

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://www.juheyunku.com/sql/oracle/3568.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

oracle表空单清理常用代码段整理

2020-12-14 编辑:

group by tablespace_name

复制代码 代码如下:

select 'drop table '||segment_name ||';' from dba_segments where tablespace_name='TEMPTABS' and segment_name like 'TT%' and segment_name not like '%_FILE';
#将系统UNDO表空间指向undotbs2


SQL>SELECT
group by tablespace_name


, ( select tablespace_name, sum(bytes_cached) bytes
#确保所有在UNDOTBS1的undo segment都已offline
#删除临时表空间temp02


[code]
, NVL(s.current_users, 0) current_users
AND d.tablespace_name = t.tablespace_name(+)
sqlplus '/as sysdba'


#创建TEMPTABS表空间
#重启数据库
SQL>@q_tbsFREE

FROM
AND d.extent_management like 'LOCAL'
, ( select tablespace_name, sum(bytes) bytes
, NVL(a.bytes, 0) tablespace_size
1.查询表空间使用情况:
#将系统UNDO表空间指回undotbs1
或者删除表


WHERE

复制代码 代码如下:

sqlplus system/manager@topprod

SQL>drop tablespace undotbs2 including contents and datafiles;

复制代码 代码如下:

#删除原来的临时表空间temp
from dba_temp_files
SQL>alter system set undo_tablespace=undotbs2 scope=both;
#创建一个UNDO表空间undotbs2,用作临时替换
SQL>startup
) t

SQL>create tablespace temptabs datafile '/u2/oradb/oradata/topprod/temptabs.dbf' size 4096M autoextend on next 100M;
SQL>drop tablespace temptabs including contents and datafiles;
sqlplus system/manager@topprod
3.清理UNDO表空间:(在无用户连接的状况下操作,最好在清理之前重启一下数据库)
SQL>drop tablespace temp including contents and datafiles;
) a
d.tablespace_name tablespace_name
, v$sort_segment s
, d.status tablespace_status
AND d.contents like 'TEMPORARY';
SQL>drop tablespace undotbs1 including contents and datafiles;
#创建一个临时表空间temp02,用作临时替换
4.增加系统表空间:
AND d.tablespace_name = s.tablespace_name(+)
SQL>alter system set undo_tablespace=undotbs1 scope=both;


SQL>drop tablespace temp02 including contents and datafiles;

#创建新的临时表空间temp
#删除TEMPTABS表空间

复制代码 代码如下:

SQL>alter database default temporary tablespace temp02;
from v$temp_extent_pool
#将系统临时表空间指回temp
#删除UNDO表空间undotbs2
sys.dba_tablespaces d
2.清理TEMP临时表空间:(在无用户连接的状况下操作,最好在清理之前重启一下数据库)
3.清理TEMPTABS表空间:
SQL>shutdown immediate
sqlplus '/as sysdba'
SQL>create undo tablespace undotbs1 datafile '/u2/oradb/oradata/topprod/undotbs01.dbf' size 4096M;
#删除原来的UNDO表空间undotbs1
d.tablespace_name = a.tablespace_name(+)

复制代码 代码如下:

SQL>create temporary tablespace temp tempfile '/u2/oradb/oradata/topprod/temp01.dbf' size 4096M autoextend on next 100M;

, TRUNC(NVL(t.bytes / a.bytes * 100, 0)) used_pct
SQL>alter database default temporary tablespace temp;
, NVL(t.bytes, 0) used
#创建新的临时表空间undotbs1
SQL> select SEGMENT_NAME ,STATUS ,TABLESPACE_NAME from dba_rollback_segs;
SQL>startup
#将系统临时表空间指向temp02
#重启数据库
SQL>create undo tablespace undotbs2 datafile '/u2/oradb/oradata/topprod/undotbs02.dbf' size 10M autoextend on next 10M;
SQL>create temporary tablespace temp02 tempfile '/u2/oradb/oradata/topprod/temp02.dbf' size 10M autoextend on next 10M;
alter tablespace SYSTEM add datafile '/u2/oradb/oradata/topprod/system02.dbf' size 2000M autoextend on next 10M;

复制代码 代码如下:

2.查询temp使用方法:
SQL>shutdown immediate

alter tablespace SYSAUX add datafile '/u2/oradb/oradata/topprod/sysaux02.dbf' size 2000M autoextend on next 10M;

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://www.juheyunku.com/sql/oracle/3568.shtml

相关文章

风云图片

推荐阅读

返回oracle频道首页