ORACLE 查看当前用户信息(用户,表视图,索引,表空间,同义词,存储过程,约束条件)

  1. 1、用户   
  2.   查看当前用户的缺省表空间  
  3.   
  4.   SQL>select username,default_tablespace from user_users;  
  5.   
  6.   查看当前用户的角色  
  7.   
  8.   SQL>select * from user_role_privs;  
  9.   
  10.   查看当前用户的系统权限和表级权限  
  11.   
  12.   SQL>select * from user_sys_privs;  
  13.   
  14.   SQL>select * from user_tab_privs;  
  15.   
  16.   显示当前会话所具有的权限  
  17.   
  18.   SQL>select * from session_privs;  
  19.   
  20.   显示指定用户所具有的系统权限  
  21.   
  22.   SQL>select * from dba_sys_privs where grantee='GAME';  
  23.   
  24.   2、表  
  25.   
  26.   查看用户下所有的表  
  27.   
  28.   SQL>select * from user_tables;  
  29.   
  30. SELECT * FROM ALL_TABLES;  
  31.   
  32.   查看名称包含log字符的表  
  33.   
  34.   SQL>select object_name,object_id from user_objects  
  35.   
  36.   where instr(object_name,'LOG')>0;  
  37.   
  38.   查看某表的创建时间  
  39.   
  40.   SQL>select object_name,created from user_objects where object_name=upper('&table_name');  
  41.   
  42.   查看某表的大小  
  43.   
  44.   SQL>select sum(bytes)/(1024*1024) as "size(M)" from user_segments  
  45.   
  46.   where segment_name=upper('&table_name');  
  47.   
  48.   查看放在ORACLE的内存区里的表  
  49.   
  50.   SQL>select table_name,cache from user_tables where instr(cache,'Y')>0;  
  51.   
  52.   3、索引  
  53.   
  54.   查看索引个数和类别  
  55.   
  56.   SQL>select index_name,index_type,table_name from user_indexes order by table_name;  
  57.   
  58.   查看索引被索引的字段  
  59.   
  60.   SQL>select * from user_ind_columns where index_name=upper('&index_name');  
  61.   
  62.   查看索引的大小  
  63.   
  64.   SQL>select sum(bytes)/(1024*1024) as "size(M)" from user_segments  
  65.   
  66.   where segment_name=upper('&index_name');  
  67.   
  68.   4、序列号  
  69.   
  70.   查看序列号,last_number是当前值  
  71.   
  72.   SQL>select * from user_sequences;  
  73.   
  74.   5、视图  
  75.   
  76.   查看视图的名称  
  77.   
  78.   SQL>select view_name from user_views;  
  79.   
  80.   查看创建视图的select语句  
  81.   
  82.   SQL>set view_name,text_length from user_views;  
  83.   
  84.   SQL>set long 2000; 说明:可以根据视图的text_length值设定set long 的大小  
  85.   
  86.   SQL>select text from user_views where view_name=upper('&view_name');  
  87.   
  88.   6、同义词  
  89.   
  90.   查看同义词的名称  
  91.   
  92.   SQL>select * from user_synonyms;  
  93.   
  94. SELECT * FROM ALL_SYSNONYMS;  
  95.   
  96.   7、约束条件  
  97.   
  98.   查看某表的约束条件  
  99.   
  100.   SQL>select constraint_name, constraint_type,search_condition, r_constraint_name  
  101.   
  102.   from user_constraints where table_name = upper('&table_name');  
  103.   
  104.   SQL>select c.constraint_name,c.constraint_type,cc.column_name  
  105.   
  106.   from user_constraints c,user_cons_columns cc  
  107.   
  108.   where c.owner = upper('&table_owner') and c.table_name = upper('&table_name')  
  109.   
  110.   and c.owner = cc.owner and c.constraint_name = cc.constraint_name  
  111.   
  112.   order by cc.position;  
  113.   
  114.   8、存储函数和过程  
  115.   
  116.   查看函数和过程的状态  
  117.   
  118.   SQL>select object_name,status from user_objects where object_type='FUNCTION';  
  119.   
  120.   SQL>select object_name,status from user_objects where object_type='PROCEDURE';  
  121.   
  122.   查看函数和过程的源代码  
  123.   
  124.   SQL>select text from all_source where owner=user and name=upper('&plsql_name');  

posted on 2019-03-27 10:08  辉仔一刀  阅读(3250)  评论(0编辑  收藏  举报