ORACLE常用语句合集

查询库中所有表空间:

select tablespace_name from dba_tablespaces;
select tablespace_name from user_tablespaces;

查询使用过的表空间:

select distinct tablespace_name from dba_all_tables;
select distinct tablespace_name from user_all_tables;

查询表空间中所有表名:

select table_name from dba_all_tables where tablespace_name = tablespacename;

查询系统用户:

select * from all_users
select * from dba_users

查询当前连接的用户:

select * from v$session

查询当前用户权限:

select * from session_privs

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

select * from user_source

查看表空间使用情况:
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;

 

posted @ 2017-12-25 18:08  昨夜的风  阅读(422)  评论(0编辑  收藏  举报