当前位置: 网学 > 编程文档 > ORACLE > 正文

Oracle维护常用SQL语句

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/19
下载{$ArticleTitle}原创论文样式
S, PARSE_CALLS, DISK_READS,

  BUFFER_GETS, ROWS_PROCESSED FROM V$SQLAREA

  

  21、查看object分类数量

  select decode (o.type#,1,''''INDEX'''' , 2,''''TABLE'''' , 3 , ''''CLUSTER'''' , 4, ''''VIEW'''' , 5 ,

  ''''SYNONYM'''' , 6 , ''''SEQUENCE'''' , ''''OTHER'''' ) object_type , count(*) quantity from

  sys.obj$ o where o.type# > 1 group by decode (o.type#,1,''''INDEX'''' , 2,''''TABLE'''' , 3

  , ''''CLUSTER'''' , 4, ''''VIEW'''' , 5 , ''''SYNONYM'''' , 6 , ''''SEQUENCE'''' , ''''OTHER'''' ) union select

  ''''COLUMN'''' , count(*) from sys.col$ union select ''''DB LINK'''' , count(*) from

  

  22、按用户查看object种类

  select u.name schema, sum(decode(o.type#, 1, 1, NULL)) indexes,

  sum(decode(o.type#, 2, 1, NULL)) tables, sum(decode(o.type#, 3, 1, NULL))

  clusters, sum(decode(o.type#, 4, 1, NULL)) views, sum(decode(o.type#, 5, 1,

  NULL)) synonyms, sum(decode(o.type#, 6, 1, NULL)) sequences,

  sum(decode(o.type#, 1, NULL, 2, NULL, 3, NULL, 4, NULL, 5, NULL, 6, NULL, 1))

  others from sys.obj$ o, sys.user$ u where o.type# >= 1 and u.user# =

  o.owner# and u.name <> ''''PUBLIC'''' group by u.name order by

  sys.link$ union select ''''CONSTRAINT'''' , count(*) from sys.con$

  

  23、有关connection的相关信息

  1)查看有哪些用户连接

  select s.osuser os_user_name, decode(sign(48 - command), 1, to_char(command),

  ''''Action Code #''''    to_char(command) ) action, p.program oracle_process,

  status session_status, s.terminal terminal, s.program program,

  s.username user_name, s.fixed_table_sequence activity_meter, '''''''' query,

  0 memory, 0 max_memory, 0 cpu_usage, s.sid, s.serial# serial_num

  from v$session s, v$process p where s.paddr=p.addr and s.type = ''''USER''''

  order by s.username, s.osuser

  2)根据v.sid查看对应连接的资源占用等情况

  select n.name,

  v.value,

  n.class,

  n.statistic#

  from v$statname n,

  v$sesstat v

  where v.sid = 71 and

  v.statistic# = n.statistic#

  order by n.class, n.statistic#

  3)根据sid查看对应连接正在运行的sql

  select /*+ PUSH_SUBQ */

  command_type,

  sql_text,

  sharable_mem,

  persistent_mem,

  runtime_mem,

  sorts,

  version_count,

  loaded_versions,

  open_versions,

  users_opening,

  executions,

  users_executing,

  loads,

  first_load_time,

  invalidations,

  parse_calls,

  disk_reads,

  buffer_gets,

  rows_processed,

  sysdate start_time,

  sysdate finish_time,

  ''''>''''    address sql_address,

  ''''N'''' status

  from v$sqlarea

  where address = (select sql_address from v$session where sid = 71)

  

  24、查询表空间使用情况select a.tablespace_name "表空间名称",

  100-round((nvl(b.bytes_free,0)/a.bytes_alloc)*100,2) "占用率(%)",

  round(a.bytes_alloc/1024/1024,2) "容量(M)",

  round(nvl(b.bytes_free,0)/1024/1024,2) "空闲(M)",

  round((a.bytes_alloc-nvl(b.bytes_free,0))/1024/1024,2) "使用(
  • 上一篇资讯: Oracle里时间的应用
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号