ORACLE 오라클 유용한 쿼리

  • 링크
  • 오라클 맥스 세션수 알아보기
    • SELECT name, value 
        FROM v$parameter
       WHERE name = 'sessions'
  • 오라클 버전 알아보기
    • select * from v$version where banner like 'Oracle%';
    • #결과
      Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
  • 테이블 사용 정보 (테이블 수정 내역등)
  • 세션 메모리 사용량
    • http://kr.forums.oracle.com/forums/thread.jspa?threadID=464020
    • ttitle '1. Current pga, uga session memory'
      
      select a.sid, a.username, substr(a.program, 1, 25) as pgm, a.terminal,
      max(decode(c.name, 'session pga memory', trunc(value/1000)||'K', 0)) pga,
      max(decode(c.name, 'session uga memory', trunc(value/1000)||'K', 0)) uga
      from v$session a, v$sesstat b, v$statname c
      where a.sid = b.sid
      and b.statistic# = c.statistic#
      and c.name like 'session%'
      group by a.sid, a.username, substr(a.program, 1, 25), a.terminal;
      ttitle '2. Sum of current pga, uga session memory'
      
      select 'Current PGA, UGA session memory SUM:' as sum,
      sum(decode(c.name, 'session pga memory', trunc(value/1000),0))||'K' pga_sum,
      sum(decode(c.name, 'session uga memory', trunc(value/1000),0))||'K' uga_sum
      from v$session a, v$sesstat b, v$statname c
      where a.sid = b.sid
      and b.statistic# = c.statistic#
      and c.name like 'session%';
      ttitle '3. Max(peak) pga, pga session memory'
      
      select a.sid, a.username, substr(a.program, 1, 25) as pgm, a.terminal,
      max(decode(c.name, 'session pga memory max', trunc(value/1000)||'K', 0)) pga_max,
      max(decode(c.name, 'session uga memory max', trunc(value/1000)||'K', 0)) uga_max
      from v$session a, v$sesstat b, v$statname c
      where a.sid = b.sid
      and b.statistic# = c.statistic#
      and c.name like 'session%'
      group by a.sid, a.username, substr(a.program, 1, 25), a.terminal;
      ttitle '4. Sum of max(peak) pga, uga session memory'
      
      select 'Max(peak) PGA, UGA session memory SUM:' as sum,
      sum(decode(c.name, 'session pga memory max', trunc(value/1000), 0))||'K' pga_m_sum,
      sum(decode(c.name, 'session uga memory max', trunc(value/1000), 0))||'K' uga_m_sum
      from v$session a, v$sesstat b, v$statname c
      where a.sid = b.sid
      and b.statistic# = c.statistic#
      and c.name like 'session%';

#TEMP TABLESPACE 재생성

  1. # 임시로 사용할 템프 스페이스(TEMP2) 생성
    1. CREATE TEMPORARY TABLESPACE TEMP2
      TEMPFILE '/~~~~/temp02.dbf' SIZE 1000M;
    2. ALTER DATABASE TEMPFILE
      '/~~~~~/undotbs02.dbf' AUTOEXTEND ON NEXT 500M MAXSIZE 4000M;
  2. # DEFAULT TEMPORARY 변경(TEMP2)
    1. ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP2;
  3. # 본래의 템프 스페이스(TEMP) 삭제
    1. DROP TABLESPACE TEMP INCLUDING CONTENTS AND DATAFILES;
  4. # 템프 스페이스 재 생성
    1. CREATE TEMPORARY TABLESPACE TEMP 
      TEMPFILE '/~~~~/temp01.dbf' SIZE 1000M AUTOEXTEND ON NEXT 500M MAXSIZE 4000M;
  5. # DEFAULT TEMPORARY 변경(TEMP)
    1. ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP;
    2. ALTER USER IPSI TEMPORARY TABLESPACE TEMP;
  6. #TEMP2 삭제
    1. DROP TABLESPACE TEMP2 INCLUDING CONTENTS AND DATAFILES;

#TABLESPACE 사용량 조회

system 권한 필요

/* col file_name format a50
col tablespace_name format a20
col status format a10
col Graph format a30
set linesize 200 */
select tablespace_name, status,
   file_name FILE_NAME,
   total_mb "Total(MB)",
   used_mb  "Used(MB)",
   free_mb  "Free(MB)",
   usage    "Used%",
   free     "Free%",
   '['||rpad(nvl(lpad('+', usage/5, '+'), '='), 20, '=')||']' "Graph"
from (
Select  b.tablespace_name "TABLESPACE_NAME", max(c.status) "STATUS", b.file_name  "FILE_NAME",
to_char((b.bytes/1024/1024), '999,999,999') total_mb,
to_char(((b.bytes-sum(nvl(a.bytes,0)))/1024/1024),'999,999,999') used_mb,
to_char(((sum(nvl(a.bytes,0)))/1024/1024),'999,999,999') free_mb,
trunc((((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes))*100),2) usage,
trunc(((sum(nvl(a.bytes,0))/(b.bytes))*100),2) free
from dba_free_space a, dba_data_files b, dba_tablespaces c
where a.file_id(+) = b.file_id
     and a.tablespace_name=b.tablespace_name
     and a.tablespace_name=c.tablespace_name
group by b.tablespace_name, b.file_name, b.bytes
   union all
   select sh.tablespace_name,
       'TEMP', max(tf.NAME) NAME,
       to_char(round(sum(sh.bytes_used+sh.bytes_free)/1024/1024), '999,999,999') total_mb,
       to_char(round(sum(sh.bytes_used)/1024/1024), '999,999,999') used_mb,
       to_char(round(sum(sh.bytes_free)/1024/1024), '999,999,999') free_mb,
       round(sum(sh.bytes_used ) / sum(sh.bytes_used+sh.bytes_free) * 100) usage,
       round(sum(sh.bytes_free ) / sum(sh.bytes_used+sh.bytes_free) * 100) free
   from v$temp_space_header sh, v$tempfile tf
   where 
       sh.FILE_ID=tf.FILE#
   group by sh.tablespace_name
   order by 1
) order by STATUS, TABLESPACE_NAME


테이블별 용량

system 권한 필요

select owner,segment_name,segment_type,sum(bytes)/1024/1024 as MB
from dba_segments
where owner = :owner
GROUP BY owner,segment_name,segment_type


http://www.java2s.com/Tutorial/Oracle/0580__SQL-PLUS-Session-Environment/Showandsetautocommit.htm

oracle autocommit setting

SQL>
SQL>
SQL> set  autocommit on
SQL> show autocommit
autocommit IMMEDIATE
SQL> set  autocommit 42
SQL> show autocommit
AUTOCOMMIT ON for every 42 DML statements
SQL> set  autocommit off
SQL>
SQL>



#MD5관련.
오래된 다른 모듈도 있다.
두번째 2는 sys.dbms_crypto.HASH_MD5 가 없을때 사용하라.
LOWER(SYS.DBMS_CRYPTO.hash(utl_raw.cast_to_raw('51595f73c1c106caefe5507e0f263607'),2));

댓글
  • No Nickname
    No Comment
  • 권한이 없습니다.
    {{m_row.m_nick}}
    -
제목 작성자 날짜
공대여자
공대여자
mins01
공대여자
공대여자
공대여자
공대여자
공대여자
공대여자
공대여자
공대여자
공대여자
공대여자
공대여자
공대여자
공대여자
공대여자
공대여자