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'

  • 相关阅读:
    04 SecurityContextHolder与SecurityContext说明
    03 spring security执行流程分析
    02 spring security 自定义用户认证流程
    01 spring security入门篇
    第三周进度
    第二周进度
    一维整数组所有子数组和的最大值
    初入园子,自我介绍
    密码登录源码(jsp+java+数据库)
    第一周总结
  • 原文地址:https://www.cnblogs.com/wyett/p/oracle_basic_sql.html
Copyright © 2011-2022 走看看