Oracle 表空間擴容

2021-09-25 11:34:40 字數 2535 閱讀 5094

//查詢表空間的磁碟路徑sql

select * from dba_data_files;

//查詢表空間的大小sql m單位

select t.tablespace_name, round(sum(bytes/(1024 * 1024)), 0) ts_size

from dba_tablespaces t, dba_data_files d

where t.tablespace_name = d.tablespace_name

group by t.tablespace_name;

//修改表空間檔案大小sql

select tablespace_name "表空間",

to_char(round(bytes / 1024, 2), '99990.00')

|| '' "實有",

to_char(round(free / 1024, 2), '99990.00')

|| 'g' "現有",

to_char(round(( bytes - free ) / 1024, 2), '99990.00')

|| 'g' "使用",

to_char(round(10000 * used / bytes) / 100, '99990.00')

|| '%' "比例"

from (select a.tablespace_name tablespace_name,

floor(a.bytes / ( 1024 * 1024 )) bytes,

floor(b.free / ( 1024 * 1024 )) free,

floor(( a.bytes - b.free ) / ( 1024 * 1024 )) used

from (select tablespace_name tablespace_name,

sum(bytes) bytes

from dba_data_files

group by tablespace_name) a,

(select tablespace_name tablespace_name,

sum(bytes) free

from dba_free_space

group by tablespace_name) b

where a.tablespace_name = b.tablespace_name)

--where tablespace_name like 'cdr%' --這一句用於指定表空間名稱

查詢資料檔案指標及路徑

select b.file_id  檔案id,

b.tablespace_name  表空間,

b.file_name     物理檔名,

b.bytes       總位元組數,

(b.bytes-sum(nvl(a.bytes,0)))   已使用,

sum(nvl(a.bytes,0))        剩餘,

sum(nvl(a.bytes,0))/(b.bytes)*100 剩餘百分比

乙個資料檔案最大只能32g;

方式1:手工改變已存在資料檔案的大小

方式2:允許已存在的資料檔案自動增長

autoextend on next 100m maxsize 20480m;

方式3:增加資料檔案

其中設定的每個檔案初始分配空間為7g, autoextend on為自動增長大小,oracle單個檔案大小最大不超過32g.

sql指令碼如下:(我這裡增加兩個資料檔案,需要擴容的表空間是system)

alter tablespace system add datafile

size 7167m autoextend on ;

alter tablespace system add datafile

size 7167m autoextend on ;

oracle表空間擴容

1 查詢當前表空間使用情況 col file name format a50 col space name format a15 select b.file name file name,b.tablespace name space name,b.bytes 1024 1024 munm,b.by...

Oracle表空間擴容

oracle表空間擴容 首先檢視表空間所生的記憶體 select a.tablespace name,round a.total size total size mb round a.total size round b.free size,3 used size mb round b.free s...

oracle表空間擴容

oracle在使用中會發現,表空間不足的情況 以下介紹了如何1 查詢表空間使用率 剩餘量 2 如何擴充套件表空間容量 select tablespace name 表空間 to char round bytes 1024,2 99990.00 實有 to char round free 1024,2...