您的位置:首页 > 数据库 > Oracle

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

2017-08-17 14:32 579 查看
/* 查询表空间的名字和大小 */

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';
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: