Oacle常用语句

--查询数据库中表的记录数  按记录数排名
select  * from user_tables t where t.NUM_ROWS is not  null  order by t.NUM_ROWS  desc

--查询数据库中表的存储空间, 按空间大小排名

select * from user_segments s  where s.BYTES  is not null  order by s.BYTES desc

--查询数据库表空间是否是自动扩展

 select a.FILE_NAME,a.TABLESPACE_NAME,a.AUTOEXTENSIBLE from dba_data_files a

--查询数据库各表空间的分区情况

select a.tablespace_name,count(*) from USER_TAB_PARTITIONS a
group by a.tablespace_name

--查看数据库的分区表

 select * from user_part_tables 

--查看oracle表所有注释
select * from user_tab_comments 

--获取字段注释:

select * from user_col_comments

--查看表空间使用率

SELECT a.tablespace_name "表空间名",

       total "表空间大小",
       free "表空间剩余大小",
       (total - free) "表空间使用大小",
       total / (1024 1024 1024"表空间大小(G)",
       free / (1024 1024 1024"表空间剩余大小(G)",
       (total - free) / (1024 1024 1024"表空间使用大小(G)",
       round((total - free) / total, 4) * 100 "使用率 %"
  FROM (SELECT tablespace_name, SUM(bytes) free
          FROM dba_free_space
         GROUP BY tablespace_name) a,
       (SELECT tablespace_name, SUM(bytes) total
          FROM dba_data_files
         GROUP BY tablespace_name) b
 WHERE a.tablespace_name = b.tablespace_name
posted @ 2020-07-13 14:23  一只竹节虫  阅读(148)  评论(0编辑  收藏  举报