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

Oracle之获取SQL对应表的信息

2017-10-27 22:01 323 查看
SET LINESIZE 666

set pagesize 5000

column index_name format a30

column table_name format a26

column num_rows format 999999999

column index_type format a24

column num_rows format 999999999

column status format a8

column clustering_factor format 999999999

column degree format a10

column blevel format 9

column distinct_keys format 9999999999

column leaf_blocks format   9999999

column last_analyzed    format a10

column column_name format a25

column column_position format 9

column temporary format a2

column partitioned format a5

column partitioning_type format a7

column partition_count format 999

--1.查看表大小情况

--记录的大小

select count(*) from T1;

select count(*) from T2; 

--物理的大小

select segment_name,sum(bytes)/1024/1024 

from  user_segments 

where segment_name in ('T1',

                       'T2') 

group by segment_name;

--2.查看表是否有触发器

select OWNER, TRIGGER_NAME, TABLE_NAME, STATUS

  from dba_triggers

 where table_name in  ('T1',

                       'T2');  

 

 

---3.查看表结构情况

--查看表信息

/*

   通过temporary,partitioned,iot_type三个字段可知表的类型是否是全局临时表、是否是分区表、是否是索引组织表

   通过degree字段可得是否有被设置为并行度的属性(值大于1)

   通过观察last_analyzed字段值可知是否有正常收集,看有无值,或者是看时间是否很久以前的。

*/

select  t.table_name,

        t.num_rows,

        t.blocks,

        t.degree,

        t.last_analyzed,

        t.temporary,

        t.partitioned,

        t.iot_type,

        t.pct_free,

        t.tablespace_name

from user_tables t

where table_name in ('T1',

                     'T2')   ;                   

                 

                      

--查看分区表相关信息(user_part_tables记录分区的表的信息,user_tab_partitions记录表的分区的信息)

--了解这些表的分区是什么类型的,有多少个分区

select t.table_name,                                             

       t.partitioning_type,                                            

       t.partition_count                                               

  from user_part_tables t                                               

 where table_name in ('T1',

                      'T2') ;

         

                               

--了解这些表以什么列作为分区                                

select name,object_type, column_name                                                                                                                   

  from user_part_key_columns                                                                                 

 where name in ('T1',

                'T2') ;                 

         

--了解这些表的分区范围是多少
4000

SELECT table_name,partition_name, high_value, tablespace_name

  FROM user_tab_partitions t

 where table_name in ('T1',

                      'T2') 

 order by table_name,t.partition_position;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: