oracle 数据库中常用经典SQL查询(4)_Oracle数据库_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

oracle 数据库中常用经典SQL查询(4)

作者:黑客防线网安Oracle维护基地 来源:黑客防线网安Oracle维护基地 浏览次数:0

本篇关键词:Oracle数据库Oracle教程
黑客防线网安网讯:    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   wh...
    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) "使用(M)",
  Largest "最大扩展段(M)",
  to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') "采样时间"
  from  (select f.tablespace_name,
  sum(f.bytes) bytes_alloc,
  sum(decode(f.autoextensible,'YES',f.maxbytes,'NO',f.bytes)) maxbytes
  from dba_data_files f
  group by tablespace_name) a,
  (select  f.tablespace_name,
  sum(f.bytes) bytes_free
  from dba_free_space f
  group by tablespace_name) b,
  (select round(max(ff.length)*16/1024,2) Largest,
  ts.name tablespace_name
  from sys.fet$ ff, sys.file$ tf,sys.ts$ ts
  where ts.ts#=ff.ts# and ff.file#=tf.relfile# and ts.ts#=tf.ts#
  group by ts.name, tf.blocks) c
  where a.tablespace_name = b.tablespace_name and a.tablespace_name = c.tablespace_name
  25. 查询表空间的碎片程度
  select tablespace_name,count(tablespace_name) from dba_free_space group by tablespace_name
  having count(tablespace_name)>10;
  alter tablespace name coalesce;
  alter table name deallocate unused;
  create or replace view ts_blocks_v as
  select tablespace_name,block_id,bytes,blocks,'free space' segment_name from dba_free_space
  union all
  select tablespace_name,block_id,bytes,blocks,segment_name from dba_extents;
  select * from ts_blocks_v;
  select tablespace_name,sum(bytes),max(bytes),count(block_id) from dba_free_space
  group by tablespace_name;
  26查询有哪些数据库实例在运行
  select inst_name from v$active_instances;
  ===========================================================
  ######### 创建数据库----look $ORACLE_HOME/rdbms/admin/buildall.sql #############
  create database db01
  maxlogfiles 10
  maxdatafiles 1024
  maxinstances 2
  logfile
  GROUP 1 ('/u01/oradata/db01/log_01_db01.rdo') SIZE 15M,
  GROUP 2 ('/u01/oradata/db01/log_02_db01.rdo') SIZE 15M,
  GROUP 3 ('/u01/oradata/db01/log_03_db01.rdo') SIZE 15M,
  datafile 'u01/oradata/db01/system_01_db01.dbf') SIZE 100M,
  undo tablespace UNDO
  datafile '/u01/oradata/db01/undo_01_db01.dbf' SIZE 40M
    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-13054-1.html
网站维护教程更新时间:2012-03-23 00:50:05  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer