澳门二十一点游戏赌场 澳门二十一点游戏赌场
    您现在的位置:首页 >> 软件应用 >> SQL教程 >> 内容

    查看和监控数据库

    时间:2012/7/23 20:06:17 点击:

      核心提示:1. 查看本用户下的各种对象的SQL脚本SQL语句: 表:  select * from cat;  select * from tab;  select table_name from user_t...

    1.  查看本用户下的各种对象的SQL脚本

    SQL语句:

    表:

      select * from cat;

      select * from tab;

      select table_name from user_tables;

    视图:

      select text from user_views where view_name=upper('&view_name');

    索引:

      select index_name,table_owner,table_name,tablespace_name,status from user_indexes order by table_name;

    触发器:

      select trigger_name,trigger_type,table_owner,table_name,status from user_triggers;

    快照:

      select owner,name,master,table_name,last_refresh,next from user_snapshots order by owner,next;

    同义词:

      select * from syn;

    序列:

      select * from seq;

    数据库链路:

      select * from user_db_links;

    约束限制:

      select TABLE_NAME,CONSTRAINT_NAME,SEARCH_CONDITION,STATUS from user_constraints;

    本用户读取其他用户对象的权限:

      select * from user_tab_privs;

    本用户所拥有的系统权限:

      select * from user_sys_privs;

    用户:

      select * from all_users order by user_id;

    表空间剩余自由空间情况:

      select tablespace_name,sum(bytes) 总字节数,max(bytes),count(*) from dba_free_space group by tablespace_name;

    数据字典:

      select table_name from dict order by table_name;

    锁及资源信息:

      select * from v$lock;不包括DDL锁

    数据库字符集:

      select name,value$ from props$ where name='NLS_CHARACTERSET';

    inin.ora参数:

      select name,value from v$parameter order by name;

    SQL共享池:

      select sql_text from v$sqlarea;

    数据库:

      select * from v$database

    控制文件:

      select * from V$controlfile;

    重做日志文件信息:

      select * from V$logfile;

    来自控制文件中的日志文件信息:

      select * from V$log;

    来自控制文件中的数据文件信息:

      select * from V$datafile;

    NLS参数当前值:

      select * from V$nls_parameters;

    ORACLE版本信息:

      select * from v$version;

    描述后台进程:

      select * from v$bgprocess;

    查看版本信息:

      select * from product_component_version;

    2.  监控数据库

    select '查看数据库的版本' from dual;

    Select version FROM Product_component_version Where SUBSTR(PRODUCT,1,6)='Oracle';

     

    select '查看数据库库对象' from dual;

    select owner, object_type, status, count(*) count# from all_objects group by owner, object_type, status;

     

    select '查看数据库的创建日期和归档方式' from dual;

    Select Created, Log_Mode, Log_Mode From V$Database;

     

    select '查看控制文件' from dual;

    select name from v$controlfile;

     

    select '查看表空间的名称及大小' from dual;

    select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size from dba_tablespaces t, dba_data_files d where t.tablespace_name = d.tablespace_name group by t.tablespace_name;

     

    select '查看表空间物理文件的名称及大小' from dual;

    select tablespace_name, file_id, file_name, round(bytes/(1024*1024),0) total_space from dba_data_files order by tablespace_name;

     

    select '查看表空间的使用情况' from dual;

    select sum(bytes)/(1024*1024) as free_space,tablespace_name from dba_free_space group by tablespace_name ;

    SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED, C.BYTES FREE, (B.BYTES*100)/A.BYTES "% USED",(C.BYTES*100)/A.BYTES "% FREE"

    FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C

    WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME;

     

    select '查看日志文件' from dual;

    select member from v$logfile;

     

    select '查看回滚段名称及大小' from dual;

    select segment_name, tablespace_name, r.status, (initial_extent/1024) InitialExtent,(next_extent/1024) NextExtent, max_extents, v.curext CurExtent From dba_rollback_segs r, v$rollstat v Where r.segment_id = v.usn(+) order by segment_name;

     

    作者:佚名 来源:不详

  • 上一篇:NULL及DUAL详解
  • 下一篇:建立数据库链接
  • 共有评论 0相关评论
    发表我的评论
    • 大名:
    • 内容:
  • 澳门二十一点游戏赌场(www.0769online.com) © 2018 版权所有 All Rights Reserved. 邮箱:103150@qq.com 业务QQ:103150 手机:13549753683

    Power By Laoy8 SQL 3.0SP1 粤ICP备10098668号
  •