oracle 创建 undo tablespace

os: centos 7.4
db: oracle 12.1.0.2

A bigfile tablespace contains only one data file or temp file, which can contain up to approximately 4 billion (2的32次方) blocks. The minimum size of the single data file or temp file is 12 megabytes (MB) for a tablespace with 32K blocks and 7MB for a tablespace with 8K blocks. The maximum size of the single data file or temp file is 128 terabytes (TB) for a tablespace with 32K blocks and 32TB for a tablespace with 8K blocks.

A smallfile tablespace is a traditional Oracle tablespace, which can contain 1022 data files or temp files, each of which can contain up to approximately 4 million (2的22次方) blocks.

bigfile tablespace 只能包含一个文件,不可以再添加.block 是 2的32次方(4G) 寻址
smallfile tablespace 是可以添加至1022个数据文件.block 是 2的22次方(4M) 寻址

create undo smallfile tablespace

CREATE UNDO TABLESPACE peiyb_undo
DATAFILE '/data/orcl/pdborcl/peiyb_undo01.dbf' 
SIZE 1G 
AUTOEXTEND ON NEXT 1G 
MAXSIZE UNLIMITED
ONLINE
RETENTION GUARANTEE
BLOCKSIZE 8K
FLASHBACK ON;

create undo bigfile tablespace

CREATE BIGFILE UNDO TABLESPACE peiyb_undo 
DATAFILE '/data/orcl/pdborcl/peiyb_undo01.dbf' 
SIZE 1G 
AUTOEXTEND ON NEXT 1G 
MAXSIZE UNLIMITED
ONLINE
RETENTION GUARANTEE
BLOCKSIZE 8K
FLASHBACK ON;

add undo smallfile

ALTER TABLESPACE peiyb_undo
  ADD DATAFILE '/data/orcl/pdborcl/peiyb_undo02.dbf'
  SIZE 1G
  AUTOEXTEND ON NEXT 1G
  MAXSIZE UNLIMITED;

resize undo smallfile

select 'alter database datafile '''||dt.file_name||''' autoextend on next 1g maxsize 30g; ', 
       dt.*,
       dts.*
from dba_data_files dt,
     dba_tablespaces dts
where 1=1
  and dt.tablespace_name = dts.tablespace_name
  and dts.contents='UNDO'
  and dts.bigfile = 'NO'
;

ALTER DATABASE DATAFILE '/data/orcl/pdborcl/peiyb_undo02.dbf'
RESIZE 10G;
 
ALTER DATABASE DATAFILE '/data/orcl/pdborcl/peiyb_undo02.dbf'
AUTOEXTEND ON NEXT 1G 
MAXSIZE UNLIMITED;

undo_retention & retention guarantee

SQL> alter system set undo_retention=3600;
SQL> alter tablespace UNDOTBS1 retention guarantee; 

Switching Undo Tablespaces

SQL>  alter system set undo_tablespace = undotbs_02;

参考:
https://docs.oracle.com/database/121/SQLRF/statements_7003.htm#SQLRF01403
https://docs.oracle.com/cd/E11882_01/server.112/e25494/tspaces.htm#ADMIN11356
https://docs.oracle.com/database/121/SQLRF/statements_3002.htm#SQLRF01002

<< Managing Undo >>
https://docs.oracle.com/en/database/oracle/oracle-database/19/admin/managing-undo.html#GUID-2C865CF9-A8B5-4BF1-A451-E8C08D3611F0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

数据库人生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值