Oracle扩充表空间步骤详解数据库

Oracle
扩充
空间步骤
 

通过查询数据库系统中的数据字典表(data dictionary tables)获取表空间的相关信息,首先使用客户端工具连接到数据库,这些工具可以是SQLPLUS字符工具、TOAD、PL/SQL等,连接到数据库后执行如下的查询语句:

  select

  a.a1 表空间名称,

  c.c2 类型,

  c.c3 区管理,

  b.b2/1024/1024 表空间大小M,

  (b.b2-a.a2)/1024/1024 已使用M,

  substr((b.b2-a.a2)/b.b2*100,1,5) 利用率

  from

  (select tablespace_name a1, sum(nvl(bytes,0)) a2 from dba_free_space group by tablespace_name) a,

  (select tablespace_name b1,sum(bytes) b2 from dba_data_files group by tablespace_name) b,

  (select tablespace_name c1,contents c2,extent_management c3 from dba_tablespaces) c

  where a.a1=b.b1 and c.c1=b.b1;

  该语句通过查询dba_free_space,dba_data_files,dba_tablespaces这三个数据字典表,得到了表空间名称,表空间类型,区管理类型,以”兆”为单位的表空间大小,已使用的表空间大小及表空间利用率。dba_free_space表描述了表空间的空闲大小,dba_data_files表描述了数据库中的数据文件,dba_tablespaces表描述了数据库中的表空间。通过查询数据库系统中的数据字典表(data dictionary tables)获取表空间的相关信息,首先使用客户端工具连接到数据库,这些工具可以是SQLPLUS字符工具、TOAD、PL/SQL等,连接到数据库后执行如下的查询语句:

  select

  a.a1 表空间名称,

  c.c2 类型,

  c.c3 区管理,

  b.b2/1024/1024 表空间大小M,

  (b.b2-a.a2)/1024/1024 已使用M,

  substr((b.b2-a.a2)/b.b2*100,1,5) 利用率

  from

  (select tablespace_name a1, sum(nvl(bytes,0)) a2 from dba_free_space group by tablespace_name) a,

  (select tablespace_name b1,sum(bytes) b2 from dba_data_files group by tablespace_name) b,

  (select tablespace_name c1,contents c2,extent_management c3 from dba_tablespaces) c

  where a.a1=b.b1 and c.c1=b.b1;

  该语句通过查询dba_free_space,dba_data_files,dba_tablespaces这三个数据字典表,得到了表空间名称,表空间类型,区管理类型,以”兆”为单位的表空间大小,已使用的表空间大小及表空间利用率。dba_free_space表描述了表空间的空闲大小,dba_data_files表描述了数据库中的数据文件,dba_tablespaces表描述了数据库中的表空间。

–0、以oracle用户登陆数据库对应的IP
 
–1、以sysdba登陆数据库
sqlplus /
as
sysdba
 
–2、查询出表空间数据文件列表
select
file_name
from
dba_data_files
where
tablespace_name=
‘表空间名称’
;
 
–3、可另开一窗口查看某一表空间数据文件的大小,以便增加指定大小的表空间。
ll /TABLESPACE/ORADATA/XXXXXXXXXXXX.dbf
 
–4、对指定文件进行RESIZE扩充大小
alter
database
datafile
‘/TABLESPACE/ORADATA/XXXXXXXXXXXX.dbf’
RESIZE 1G;
 
–附表空间管理语句:
–增加数据文件
alter
tablespace 表空间名称
add
datafile
‘表空间文件路径如:/path/file_name.dbf’
size
128M;
 
–删除数据文件
alter
tablespace 表空间名称
drop
datafile
‘表空间文件路径’
;
 
–删除整个表空间
drop
tablespace 表空间名称 including contents(同时删除表空间文件增加
‘ and datafiles ‘
)
cascade
constraints;
 
–自动扩展表空间格式, 需要定义最大扩展到多少
alter
database
datafile
‘表空间文件全路径’
autoextend
on
next
每次自动扩展的大小  MAXSIZE 定义最大扩展到多少;

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/4363.html

(0)
上一篇 2021年7月16日
下一篇 2021年7月16日

相关推荐

发表回复

登录后才能评论