先创建用户
#sqlplus /nolog
SQL> conn / as sysdba;
SQL>create user username identified by password
SQL> grant dba to username;
SQL> conn username/password
imp 用户名/密码@服务名标识 file=dmp文件路径 fromuser=导入的用户
oracle数据检查各个表空间的路劲及其使用率
select
b.file_name 物理文件名,
b.tablespace_name 表空间,
b.bytes/1024/1024 大小M,
(b.bytes-sum(nvl(a.bytes,0)))/1024/1024 已使用M,
substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) 利用率
from dba_free_space a,dba_data_files b
where a.file_id=b.file_id
group by b.tablespace_name,b.file_name,b.bytes
order by b.tablespace_name;
SELECT a.tablespace_name "表空间名",
total "表空间大小",
free "表空间剩余大小",
(total - free) "表空间使用大小",
total / (1024 * 1024 * 1024) "表空间大小(G)",
free / (1024 * 1024 * 1024) "表空间剩余大小(G)",
(total - free) / (1024 * 1024 * 1024) "表空间使用大小(G)",
round((total - free) / total, 4) * 100 "使用率 %"
FROM (SELECT tablespace_name, SUM(bytes) free
FROM dba_free_space
GROUP BY tablespace_name) a,
(SELECT tablespace_name, SUM(bytes) total
FROM dba_data_files
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name;
重新给某个表空间扩容
alter database datafile 'D:\ORACLE\ORADATA\SZGD\SYSTEM01.DBF' resize 10G;
增加新的数据文件
alter tablespace system add datafile '/opt/oracle/oradata/ora11g/system2.dbf' size 10G autoextend off;
第一步:查看表空间的名字及文件所在位置:
select tablespace_name, file_id, file_name,round(bytes/(1024*1024),0) total_space from dba_data_files
order by tablespace_name;
第二步;
扩大表空间
alter database datafile 'D:\ORACLE\ORADATA\LYGL\SDE.DBF' resize 20480m;
b增加新的数据文件
alter tablespace SDE add datafile 'D:\ORACLE\ORADATA\LYGL\SDE01.DBF' size 20480m;
设置表空间的自动增长
alter database datafile ' D:\ORACLE\ORADATA\LYGL\SDE01.DBF ' autoextend on next 100m maxsize 20480m;
设置表空间无限大小(最大磁盘空间)
alter database datafile 'D:\ORACLETABLESPACE\IDPC.DBF' autoextend on next 100m maxsize unlimited;
网友评论