标签:类型 mono pac dict orm table select lan _id
--sys 登录,查询表空间
SELECT FREE.TABLESPACE_NAME,
ROUND(TOTAL.MB, 2) AS TOTAL_MB,
ROUND(TOTAL.MB - FREE.MB, 2) AS USED_MB,
ROUND(TOTAL.MB, 2) - ROUND(TOTAL.MB - FREE.MB, 2) FREE_MB,
ROUND((1 - FREE.MB / TOTAL.MB) * 100, 2) || ‘%‘ AS USED_PCT,
TOTAL.FILE_NAMEFROM (SELECT TABLESPACE_NAME,
SUM(BYTES) / 1024 / 1024 AS MB FROM DBA_FREE_SPACE GROUP BY TABLESPACE_NAME) FREE,
(SELECT TABLESPACE_NAME,
FILE_NAME,
SUM(BYTES) / 1024 / 1024 AS MB FROM DBA_DATA_FILES GROUP BY TABLESPACE_NAME,
FILE_NAME) TOTAL
WHERE FREE.TABLESPACE_NAME = TOTAL.TABLESPACE_NAME;--sys 登录,查询临时表空间
SELECT D.TABLESPACE_NAME,
ROUND((F.BYTES_FREE + F.BYTES_USED) / 1024 / 1024, 2) TOTAL_MB,
ROUND(NVL(P.BYTES_USED, 0) / 1024 / 1024, 2) USED_MB,
ROUND(((F.BYTES_FREE + F.BYTES_USED) - NVL(P.BYTES_USED, 0)) / 1024 / 1024, 2) FREE_MB,
ROUND((ROUND(NVL(P.BYTES_USED, 0) / 1024 / 1024, 2) /
ROUND((F.BYTES_FREE + F.BYTES_USED) / 1024 / 1024, 2)) * 100,
2) || ‘%‘ AS USED_PCT,
D.FILE_NAME "Datafile name"FROM SYS.V_$TEMP_SPACE_HEADER F, DBA_TEMP_FILES D, SYS.V_$TEMP_EXTENT_POOL P
WHERE F.TABLESPACE_NAME(+) = D.TABLESPACE_NAME
AND F.FILE_ID(+) = D.FILE_ID
AND P.FILE_ID(+) = D.FILE_ID
ORDER BY D.TABLESPACE_NAME;SELECT T3.USERNAME, T3.DEFAULT_TABLESPACE, T3.TEMPORARY_TABLESPACE, T2.NAME, T4.FILE_NAME
FROM V$TABLESPACE T1, V$DATAFILE T2, DBA_USERS T3, DBA_TEMP_FILES T4
WHERE T1.TS# = T2.TS#
AND T1.NAME = T3.DEFAULT_TABLESPACE
AND T3.TEMPORARY_TABLESPACE = T4.TABLESPACE_NAME;
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;
1. 查询oracle中所有用户信息
select * from dba_users;
2. 只查询用户和密码
select username,password from dba_users;
3. 查询当前用户信息
select * from dba_ustats;
4. 查询用户可以访问的视图文本
select * from dba_varrays;
5. 查询数据库中所有视图的文本
select * from dba_views;
6. 查看当前用户的表
select table_name from user_tables;
7. 查看所有用户的表
select table_name from all_tables;
8. 查看系统表
select table_name from dba_tables;
9.查看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表描述了数据库中的表空间。
上面语句中from子句后有三个select语句,每个select语句相当于一个视图,视图的名称分别为a、b、c,通过它们之间的关联关系,我们得到了表空间的相关信息。
标签:类型 mono pac dict orm table select lan _id
原文地址:http://www.cnblogs.com/hifeego/p/6575765.html