oracle中关于表空间,用户,表相关的查询语句

来源:互联网 发布:如何注册淘宝达人 编辑:程序博客网 时间:2024/06/07 03:21
/* 查询表空间的名字和大小 */
select tablespace_name "表空间的名字", sum(bytes)/1024/1024 "表空间大小" from dba_data_files group by tablespace_name ;


/*查看表空间下有哪些用户 */
select distinct a.owner  from  dba_segments a where  a.tablespace_name='TS_MHS5';  


/*查看当前登录的用户名*/
select user  from  dual;
select * from user_users;


/*查看当前用户名拥有的角色和权限*/
select * from user_role_privs;
select * from session_privs;


/*查看用户下有多少表*/
select * from user_tables where  table_name like '%patient%';
select count(*) from  user_tables;   /*user_tables是当前用户的所有表,用这个可以缩小查找的范围*/
select * from dba_tables where owner='MHS5';  /*dba_tables是管理员可以看到的数据库中所有的表*/
select count(*) from all_tables where owner='MHS5';  /*all_tables显示用户有权限看到的所有的表,包括系统表*/
select distinct  table_name from  user_tables;


/*查看用户某一张表的结构 */
desc  mhs5.patient_info; /*要在命令模式下使用 */
select * from all_tab_columns;
select * from user_col_comments; --查询当前用户的表的列名和注释 


/*查看用户的某一张的大小 ,在pl/sql 中不好用,不知道为什么*/
select sum(bytes)/1024/1024 "表大小(M)" from user_segments where segment_name='mhs5.patient_info_mid';

原创粉丝点击