表空间查询

1、查询数据库中的表空间名称

1)查询所有表空间

select tablespace_name from dba_tablespaces; 
select tablespace_name from user_tablespaces; 

2)查询使用过的表空间  

select distinct tablespace_name from dba_all_tables;

select distinct tablespace_name from user_all_tables; 

2、查询表空间中所有表的名称

select table_name from dba_all_tables where tablespace_name = tablespacename

3、查询系统用户

select * from all_users
select * from dba_users

4、查看当前连接用户

select * from v$session

5、查看当前用户权限

select * from session_privs

6、查看所有的函数和存储过程

select * from user_source

其中TYPE包括:PROCEDURE、FUNCTION

7、查看表空间使用情况

select a.file_id "FileNo",
       a.tablespace_name "表空间",
       a.bytes "Bytes",
       a.bytes - sum(nvl(b.bytes, 0)) "已用",
       sum(nvl(b.bytes, 0)) "空闲",
       sum(nvl(b.bytes, 0)) / a.bytes * 100 "空闲百分率"
  from dba_data_files a, dba_free_space b
 where a.file_id = b.file_id(+)
 group by a.tablespace_name, a.file_id, a.bytes
 order by a.tablespace_name;

原文地址:https://www.cnblogs.com/hllnj2008/p/4084335.html