All technological notes.
data files:
Oracle Database physically stores tablespace data in data files. 存储表空间数据.
Each nonpartitioned schema object and each partition of an object is stored in its own segment, which belongs to only one tablespace.
segment.Segment is stored in one tablespace.TBSP vs data file
tablespace consists of one or more data files. 一个 tbsp 对应一个或多个 dfdata files located in each tablespace of the database. 数据在 df 中.segment can span one or more data files, but it cannot span multiple tablespaces. segment 可以跨 df, 但不能跨 tbsp.SYSTEM and SYSAUX tablespaces.
data files of any database for the SYSTEM tablespace during database creation.创建时, 先创建 SYSTEM tbsp 的 df.SYSTEM tablespace contains the data dictionary, a set of tables that contains database metadata.undo tablespace and a temporary tablespace (usually named TEMP).
- One tbsp
- 2 DF: 一个 tbsp 可以多个 DF
- segment:
- index 和 table 都是对象, 对应相应的 segment
- segment 可以跨 df
- segment 在一个 tbsp 之下.
Permanent Data Files
schema objects) in permanent tablespaces.Temporary Data Files
tablespaces
tablespace contains schema objects only for the duration of a session.Temp files vs permanent data files
temp files.NOLOGGING mode
redo generated for them.temp files.ALTER DATABASE statement.Views:
| TEMP | Permenant | |
|---|---|---|
| dynamic performance view | V$TEMPFILE |
V$DATAFILE |
| data dictionary view | DBA_TEMP_FILES |
DBA_DATA_FILES |
Every data file is either online (available) or offline (unavailable).
The database cannot access offline data files until they are brought online.离线 df 不能访问
The database takes a data file offline automatically if the database cannot write to it.
Reason to be taken offline:
TBSP: offline/online
data files of a tablespace temporarily unavailable by taking the tablespace itself offline. tbsp 离线, 全部 df 离线.Move df:
ALTER DATABASE MOVE DATAFILEwrite once read many (WORM) driveASMdata file header
data file
creation of a data file for a tablespace
data file header.user data.segments of the associated tablespace.As the data grows in a tablespace:
extents for the segment.types of space in a data file:
Extents are
fragmented free space
fragmented free space.
| Views | Description |
|---|---|
CDB_DATA_FILES |
describes all database files in open database. |
DBA_DATA_FILES |
describes database files. |
V$DATAFILE |
displays datafile information from the control file. |
Columns:
BYTES:
USER_BYTES:
MAXBYTES:
BLOCKS:
MAXBLOCKS:
USER_BLOCKS:
INCREMENT_BY:
CDB_DATAFILES: Include all open PDBshow con_name;
--CDB$ROOT
ALTER PLUGGABLE DATABASE ALL OPEN;
SELECT
CON_ID
,TABLESPACE_NAME
,FILE_NAME
,STATUS
,ONLINE_STATUS
,BYTES/(1024*1024) "BYTES"
,AUTOEXTENSIBLE
FROM cdb_data_files
ORDER BY 1, 2;

ALTER session SET container=orclpdb;
show con_name;
--ORCLPDB
SELECT
CON_ID
,TABLESPACE_NAME
,FILE_NAME
,STATUS
,ONLINE_STATUS
,BYTES/(1024*1024) "BYTES"
,AUTOEXTENSIBLE
FROM cdb_data_files
ORDER BY 1, 2;

DBA_DATA_FILES: Current Containershow con_name;
--CDB$ROOT
ALTER PLUGGABLE DATABASE ALL OPEN;
SELECT
TABLESPACE_NAME
,FILE_NAME
,STATUS
,ONLINE_STATUS
,BYTES/(1024*1024) "BYTES"
,AUTOEXTENSIBLE
FROM DBA_DATA_FILES
ORDER BY 1, 2;

ALTER session SET container=orclpdb;
show con_name;
--ORCLPDB
SELECT
TABLESPACE_NAME
,FILE_NAME
,STATUS
,ONLINE_STATUS
,BYTES/(1024*1024) "BYTES"
,AUTOEXTENSIBLE
FROM DBA_DATA_FILES
ORDER BY 1, 2;

v$datafile: including closed PDBshow con_name;
--CDB$ROOT
ALTER PLUGGABLE DATABASE ALL OPEN;
SELECT
CON_ID
,TS#
,STATUS
,ENABLED
,NAME
,BYTES/(1024*1024) "BYTES"
FROM V$DATAFILE
ORDER BY 1, 2;

ALTER session SET container=orclpdb;
show con_name;
--ORCLPDB
SELECT
CON_ID
,TS#
,STATUS
,ENABLED
,NAME
,BYTES/(1024*1024) "BYTES"
FROM V$DATAFILE
ORDER BY 1, 2;

| Views | Description |
|---|---|
CDB_TEMP_FILES |
describes all temporary files (tempfiles) in open database. |
DBA_TEMP_FILES |
describes all temporary files (tempfiles) in current database. |
V$TEMPFILE |
displays temp file information. |
A tempfile is a file that is part of an Oracle database. Tempfiles are used with TEMPORARY TABLESPACES
Temporary tablespaces are used for special operations, particularly for sorting data results on disk and for hash joins in SQL. For SQL with millions of rows returned, the sort operation is too large for the RAM area and must occur on disk. The temporary tablespace is where this takes place
CDB_TEMP_FILES: Include all open PDBshow con_name;
--CDB$ROOT
ALTER PLUGGABLE DATABASE ALL OPEN;
SELECT
CON_ID
,TABLESPACE_NAME
,FILE_NAME
,STATUS
,BYTES/(1024*1024) "BYTES"
,AUTOEXTENSIBLE
FROM cdb_temp_files
ORDER BY 1, 2;

ALTER session SET container=orclpdb;
show con_name;
--ORCLPDB
SELECT
CON_ID
,TABLESPACE_NAME
,FILE_NAME
,STATUS
,BYTES/(1024*1024) "BYTES"
,AUTOEXTENSIBLE
FROM cdb_temp_files
ORDER BY 1, 2;

DBA_TEMP_FILES: Current ContainerALTER session SET container=cdb$root;
show con_name;
--CDB$ROOT
ALTER PLUGGABLE DATABASE ALL OPEN;
SELECT
TABLESPACE_NAME
,FILE_NAME
,STATUS
,BYTES/(1024*1024) "BYTES"
,AUTOEXTENSIBLE
FROM DBA_TEMP_FILES
ORDER BY 1, 2;

ALTER session SET container=orclpdb;
show con_name;
--ORCLPDB
SELECT
TABLESPACE_NAME
,FILE_NAME
,STATUS
,BYTES/(1024*1024) "BYTES"
,AUTOEXTENSIBLE
FROM DBA_TEMP_FILES
ORDER BY 1, 2;

V$TEMPFILEshow con_name;
--CDB$ROOT
ALTER PLUGGABLE DATABASE ALL OPEN;
SELECT
CON_ID
,NAME
,STATUS
,ENABLED
,BYTES/(1024*1024) "BYTES"
FROM V$TEMPFILE
ORDER BY 1, 2;

ALTER session SET container=orclpdb;
show con_name;
--ORCLPDB
SELECT
CON_ID
,NAME
,STATUS
,ENABLED
,BYTES/(1024*1024) "BYTES"
FROM V$TEMPFILE
ORDER BY 1, 2;
