zoukankan      html  css  js  c++  java
  • oracle运维常用sql

    --查看数据文件使用率
    select a.tablespace_name,a.bytes/1024/1024 "Sum MB",(a.bytes-b.bytes)/1024/1024 "used MB",b.bytes/1024/1024 "free MB",
    round(((a.bytes-b.bytes)/a.bytes)*100,2) "percent_used"
    from
    (select tablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a,
    (select tablespace_name,sum(bytes) bytes,max(bytes) largest from dba_free_space group by tablespace_name) b
    where a.tablespace_name=b.tablespace_name
    order by ((a.bytes-b.bytes)/a.bytes) desc


    --查看表空间对应的文件
    select * from dba_data_files where tablespace_name='BAIDU_DOC';

    --添加自增长
    ALTER TABLESPACE LOGTBS ADD DATAFILE '/data/ora11g/oradata/oracle9i/logtbs26.DBF' SIZE 128M AUTOEXTEND ON NEXT 50M MAXSIZE 8192M;
    --添加固定的文件
    ALTER TABLESPACE LOGTBS ADD DATAFILE '/data/ora11g/oradata/oracle9i/logtbs27.DBF' SIZE 2048M;


    --查看表空间对应的表名
    select * from all_tables where tablespace_name='GAIBAN_DATA';
    select OWNER,TABLE_NAME,TABLESPACE_NAME from all_tables where tablespace_name='GAIBAN_DATA';
    --查看表空间对应的用户
    select * from all_tables where owner='GAIBAN';


    --查看建表sql
    select dbms_metadata.get_ddl('TABLE','T_WIKI_CITY') from ALL_TABLES;


    --查看某表空间占用较大的表
    select segment_name, sum(bytes)/1024/1024 Mbytese from dba_segments where Tablespace_name='LOGTBS' group by segment_name order by MBYTESE DESC;
    select segment_name, sum(bytes)/1024/1024 Mbytese from user_segments where segment_type='TABLE' group by segment_name;
    select segment_name, sum(bytes)/1024/1024 Mbytese from dba_segments where segment_type='TABLE' group by segment_name;


    --查看表使用的空间大小
    select segment_name, bytes from user_segments where rownum<20;

    --查看建表sql
    SELECT DBMS_METADATA.GET_DDL('TABLE','DEPT','SCOTT') FROM DUAL
    select dbms_metadata.get_ddl('INDEX','PK_DEPT','SCOTT') from dual;


    --查看表中数据行数,一小时更新一次
    select table_name,num_rows from dba_tables where table_name='T_LOG_TGLM_ENTRANCE_DATA';

    --查看表对应的用户和表空间

    select owner,table_name,tablespace_name from all_tables where table_name='t_wiki_user'

  • 相关阅读:
    同node上,两个pod通过svc访问不通
    Prometheus基于service自动添加监控
    systemd 服务管理编写
    kubernetes 控制器详解【持续完善中】
    tcpdump抓包工具
    Zabbix日志监控插件
    Spring WebFlux之HttpHandler的探索
    知秋源码解读分享系列
    Spring Framework 5.0.0.M3中文文档 翻译记录 Part I. Spring框架概览1-2.2
    Spring Framework 5.0.0.M3中文文档 翻译记录 introduction
  • 原文地址:https://www.cnblogs.com/wyett/p/oracle_basic_sql.html
Copyright © 2011-2022 走看看