oracle 创建 temporary 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 temporary smallfile tablespace


CREATE TEMPORARY TABLESPACE peiyb_temp 
TEMPFILE '/data/orcl/pdborcl/peiyb_temp01.dbf' 
SIZE 1G 
AUTOEXTEND ON NEXT 1G MAXSIZE UNLIMITED
TABLESPACE GROUP ''
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 512M;

create temporary bigfile tablespace


CREATE BIGFILE TEMPORARY TABLESPACE peiyb_temp 
TEMPFILE  '/data/orcl/pdborcl/peiyb_temp01.dbf' 
SIZE 1G 
AUTOEXTEND ON NEXT 1G MAXSIZE 34359738344K
TABLESPACE GROUP ''
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 512M;

设置成 default temporary tablespace

SQL> alter database default temporary tablespace peiyb_temp ;
SQL> drop tablespace temp;

add temporary smallfile

ALTER TABLESPACE peiyb_temp
  ADD TEMPFILE '/data/orcl/pdborcl/peiyb_temp02.dbf'
  SIZE 1G
  AUTOEXTEND ON
  NEXT 1G
  MAXSIZE UNLIMITED;

resize temporary smallfile tablespace

select 'alter database tempfile '''||dtf.file_name||''' autoextend on next 1g maxsize UNLIMITED; ', 
       dtf.*
from dba_temp_files dtf
where 1=1
;

ALTER DATABASE TEMPFILE '/data/orcl/pdborcl/peiyb_temp02.dbf'
RESIZE 1G;

ALTER DATABASE TEMPFILE '/data/orcl/pdborcl/peiyb_temp02.dbf' 
AUTOEXTEND ON NEXT 1G MAXSIZE UNLIMITED;

参考:
https://docs.oracle.com/database/121/SQLRF/statements_7003.htm#SQLRF01403

你可能感兴趣的:(#,oracle,basic,knowledge)