一些表空间查看及设置
作者:互联网
SELECT created, log_mode, log_mode FROM v$database;
--1G=1024MB
--1M=1024KB
--1K=1024Bytes
--1M=11048576Bytes
--1G=1024*11048576Bytes=11313741824Bytes
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
--10、查看用户指定的默认表空间
select default_tablespace from user_users
--11、查看用户信息
select * from user_users
--12、修改用户的永久表空间可以执行命令:
alter user user default tablespace tablespaceName
--13、修改新添加的用户的默认表空间可以执行如下命名:
alter database default tablespace tablespaceName
oracle 表空间关闭自增长 autoextend off
http://blog.itpub.net/29291882/viewspace-2088336/
1、查看有哪些数据文件是自增长的
SELECT T.TABLESPACE_NAME,D.FILE_NAME,D.AUTOEXTENSIBLE,D.BYTES,D.MAXBYTES,D.STATUS
FROM DBA_TABLESPACES T,DBA_DATA_FILES D
WHERE T.TABLESPACE_NAME =D.TABLESPACE_NAME and D.AUTOEXTENSIBLE != 'NO'
ORDER BY TABLESPACE_NAME,FILE_NAME
2 关闭掉自增长
alter database datafile '/data/oracle/oradata/orcl/nnc_data01_03.dbf' autoextend off;
https://blog.csdn.net/zhaojian1988/article/details/8789830
--表空间与数据文件使用率查看与收缩:
查看数据文件路径及名称
select file#,name from v$datafile
查看Oracle数据库中每个数据文件使用率:
select b.file_name filename,b.bytes/1024/1024 sizeM,(b.bytes-sum(nvl(a.bytes,0)))/1024/1024 usedM,substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) preuse
from dba_free_space a,dba_data_files b
where a.file_id=b.file_id
group by b.tablespace_name,file_name,b.bytes
order by b.tablespace_name; DATA_DIR
--查询路径及是否自增长
SELECT T.TABLESPACE_NAME,D.FILE_NAME,D.AUTOEXTENSIBLE,D.BYTES,D.MAXBYTES,D.STATUS
FROM DBA_TABLESPACES T,DBA_DATA_FILES D
WHERE T.TABLESPACE_NAME =D.TABLESPACE_NAME
ORDER BY TABLESPACE_NAME,FILE_NAME
--停止数据文件自增长
alter database datafile '/data/oracle/oradata/orcl/nnc_data01_03.dbf' autoextend off;
--查看指定表空间的空余空间与使用率
select df.tablespace_name,df.sum_df_m as space_m,fs.sum_fs_m free_space,to_char(trunc((df.sum_df_m-fs.sum_fs_m)/df.sum_df_m,2)*100) as "used_%"
from (select tablespace_name,sum(bytes/1024/1024) as sum_df_m from dba_data_files group by tablespace_name) df,(select tablespace_name,sum(bytes/1024/1024) as sum_fs_m from dba_free_space group by tablespace_name) fs
where df.tablespace_name=fs.tablespace_name and df.tablespace_name='USERS';
--查看数据文件名称
select file#,name from v$datafile
--查看数据文件路径、名称、大小、使用率、占用、使用率
select b.file_name filename,b.bytes/1024/1024 sizeM,(b.bytes-sum(nvl(a.bytes,0)))/1024/1024 usedM,substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) preuse
from dba_free_space a,dba_data_files b
where a.file_id=b.file_id
group by b.tablespace_name,file_name,b.bytes
order by b.tablespace_name;
--查看空余空间信息
select * from dba_free_space
--6、查看表空间的使用情况
SELECT SUM(bytes) / (1024 * 1024) AS free_space, tablespace_name
FROM dba_free_space
GROUP BY tablespace_name;
SELECT a.tablespace_name,
a.bytes total,
b.bytes used,
c.bytes free,
(b.bytes * 100) / a.bytes "% USED ",
(c.bytes * 100) / a.bytes "% FREE "
FROM sys.sm$ts_avail a, sys.sm$ts_used b, sys.sm$ts_free c
WHERE a.tablespace_name = b.tablespace_name
AND a.tablespace_name = c.tablespace_name;
标签:1024,name,查看,--,bytes,free,tablespace,设置,空间 来源: https://www.cnblogs.com/lh999/p/16083637.html