1.数据库版本信息
sql语句:select * from v$version
结果:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Pro |
PL/SQL Release 10.2.0.1.0 - Production |
CORE 10.2.0.1.0 Production |
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production |
NLSRTL Version 10.2.0.1.0 - Production |
2.表空间文件列表
sql语句: select tablespace_name , file_id, file_name,round(bytes/(1024*1024),0) total_space ,AUTOEXTENSIBLE from dba_data_files order by tablespace_name
结果:
表空间名称 | 文件路径id | 文件路径 | 总空间(MByte) | 是否自动增长 |
EXAMPLE | 5 | D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF | 100 | YES |
SYSAUX | 3 | D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF | 410 | YES |
SYSTEM | 1 | D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF | 530 | YES |
UNDOTBS1 | 2 | D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF | 545 | YES |
USERS | 4 | D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF | 21543 | YES |
3.表空间利用率
sql语句:
SELECT ts.tablespace_name,
round(df.totalbytes / (1024 * 1024), 0) total,
round(fr.freebytes / (1024 * 1024), 0) free,
round(df.totalbytes / (1024 * 1024), 0) -
round(fr.freebytes / (1024 * 1024), 0) used,
round((df.totalbytes - fr.freebytes) / df.totalbytes * 100, 0) uf
FROM (SELECT tablespace_name, SUM(BYTES) totalbytes
FROM dba_data_files
GROUP BY tablespace_name) df
join (SELECT tablespace_name FROM dba_tablespaces) ts
on df.tablespace_name = ts.tablespace_name
left join (SELECT tablespace_name, SUM(BYTES) freebytes
FROM dba_free_space
GROUP BY tablespace_name) fr
on df.tablespace_name = fr.tablespace_name
ORDER BY uf
结果是:各个表空间的总空间,已用空间,剩余空间,利用率。sql比较慢,初学者。请提意见