tablespaces
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tablespaces [2015/07/17 14:01] – z0hpvk | tablespaces [2025/03/08 22:24] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== Tablespaces ==== | + | ===== Tablespaces |
- | === Current Tablespace Usage === | + | ==== Current Tablespace Usage ==== |
- | < | + | < |
- | WITH Tablespace_Data as | + | |
- | ( | + | COLUMN used_pct FORMAT A11 |
- | SELECT tablespace_name, | + | COLUMN size_mb FORMAT 999,999 |
- | | + | COLUMN free_mb FORMAT 999,999 |
- | | + | COLUMN max_size_mb FORMAT 999,999 |
- | | + | COLUMN max_free_mb FORMAT 999,999 |
- | 100 - ROUND(((b.free_bytes+a.growth)/a.maxbytes) * 100) AS pct_used | + | |
- | FROM (SELECT tablespace_name, | + | SELECT tablespace_name, |
- | GREATEST(bytes, | + | size_mb, |
- | GREATEST(bytes, | + | free_mb, |
- | FROM dba_data_files) a, | + | max_size_mb, |
- | | + | max_free_mb, |
- | WHERE a.file_id = b.file_id(+) | + | TRUNC((max_free_mb/max_size_mb) * 100) AS free_pct |
- | ) | + | FROM |
- | SELECT tablespace_name, | + | |
- | sum(size_mb) SIZE_MB, | + | |
- | sum(maxsize_mb) MAXSIZE_MB, | + | |
- | sum(free_mb) FREE_MB, | + | b.max_size_mb, |
- | sum(growth_mb) GROWTH_MB, | + | a.free_mb + (b.max_size_mb - b.size_mb) AS max_free_mb |
- | round((sum(size_mb)-sum(free_mb)) / sum(maxsize_mb)*100,2) PERCENTAGE_USED | + | FROM (SELECT tablespace_name, |
- | | + | TRUNC(SUM(bytes)/1024/1024) AS free_mb |
- | group by tablespace_name;</ | + | |
- | === Changing Undo Tablespace === | + | |
- | == Create New Undo Tablespace == | + | |
+ | TRUNC(SUM(bytes)/1024/1024) AS size_mb, | ||
+ | TRUNC(SUM(GREATEST(bytes, | ||
+ | FROM | ||
+ | GROUP BY tablespace_name) b | ||
+ | | ||
+ | ) | ||
+ | ORDER BY tablespace_name; | ||
+ | </ | ||
+ | |||
+ | ==== Changing Undo Tablespace | ||
+ | === Create New Undo Tablespace | ||
< | < | ||
- | == Switch databases to new undo tablespace == | + | === Switch databases to new undo tablespace |
< | < | ||
- | == Drop old undo tablespace == | + | === Drop old undo tablespace |
< | < | ||
- | == Potential Issues == | + | === Potential Issues |
When doing the "drop undo tablespace" | When doing the "drop undo tablespace" | ||
< | < | ||
Line 49: | Line 60: | ||
< | < | ||
+ | |||
+ | ==== Temporary Tablespace ==== | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | If this command hangs then there are probably sessions still using the old temp tablespace. \\ | ||
+ | Use the following SQL to find the sessions ... | ||
+ | < | ||
+ | | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | To discover what the default temporary tablespace is ... | ||
+ | < | ||
+ | |||
+ | ==== Data File Management ==== | ||
+ | < | ||
+ | ALTER TABLESPACE USERS ADD DATAFILE '/ | ||
+ | ALTER DATABASE DATAFILE '/ | ||
+ | </ | ||
+ | |||
+ | ==== Default Tablespaces ==== | ||
+ | <code SQL> | ||
+ | SELECT * FROM database_properties WHERE property_name like ' | ||
+ | </ | ||
+ | |||
+ | ==== Resize Data Files ==== | ||
+ | <code SQL> | ||
+ | -- Report on which data files can be shrunk | ||
+ | set verify off pagesize 50 linesize 120 | ||
+ | column file_name format a60 word_wrapped | ||
+ | column smallest format 999,990 heading " | ||
+ | column currsize format 999,990 heading " | ||
+ | column savings | ||
+ | break on report | ||
+ | compute sum of savings on report | ||
+ | column value new_val blksize | ||
+ | select file_name, | ||
+ | ceil( (nvl(hwm, | ||
+ | ceil( blocks*&& | ||
+ | ceil( blocks*&& | ||
+ | ceil( (nvl(hwm, | ||
+ | from dba_data_files a, | ||
+ | ( select file_id, max(block_id+blocks-1) hwm | ||
+ | from dba_extents | ||
+ | group by file_id ) b | ||
+ | where a.file_id = b.file_id(+) | ||
+ | order by savings desc; | ||
+ | </ | ||
+ |
tablespaces.1437141691.txt.gz · Last modified: 2025/03/08 22:23 (external edit)