반응형
반응형

'Database > ORACLE' 카테고리의 다른 글

RMAN 사용법  (0) 2010.07.06
오라클 암호화 기능  (0) 2010.07.02
오라클 기본 유저 정보  (0) 2010.06.30
오라클 일괄 컴파일  (0) 2010.06.30
프로시저에서 엑셀파일 출력하기  (0) 2010.06.29
반응형

Oracle Created (Default) Users

디폴트 유저 리스트

유저

디폴트 암호

용도 및 설명

SYS

change_on_install

오라클의 가장 기본적인 메타 데이터가 저장되는 스키마가 된다. SYS소유의 테이블, 뷰 등은 오라클 시스템에 의해 실시간으로 수정되며, 인위적으로 수정되어서는 않된다.
디폴트 암호는 오라클을 인스톨하자마자 수정해야 한다.

SYSTEM

manager

SYSTEM 스키마의 테이블과 뷰는 오라클 데이터베이스의 관리정보를 보여주고, 주변 관리도구를 위해 내부적으로 사용된다.

SYSTEM 유저는X$ 테이블 등에 접근할 수 없고, 데이터베이스를 startup/shutdown 시킬수는 없지만 DBA권한을 부여받았다. 따라서 일반 사용자의 모든 스키마를 접근 가능하다.  

DBSNMP

dbsnmp

Oracle SNMP (Simple Network Management Protocol) 툴을 위한 유저로써, Oracle Intelligent Agent 등 에서 오라클 서버에 접근하기 위해 사용한다. 디폴트 암호를 수정하기 위해서는 아래와 같이 한다.

  1. Remove all Jobs and Events currently registered against this database.
  2. Stop the Intelligent Agent

Oracle7 - Oracle8i
% lsnrctl dbsnmp_stop

Oracle9i
% agentctl stop

  1. Edit the $ORACLE_HOME/network/admin/snmp_rw.ora file. Add the following parameter:

SNMP.CONNECT.<connect_string>.NAME=<username>
SNMP.CONNECT.<connect_string>.PASSWORD=<password>

The variable <connect_string> is the exact listing of the database name as it appears in the snmp_ro.ora file.

If <username> is the default (DBSNMP), there is no need to specify the user here. Only the password is required.

On UNIX, set the following permission on the "SNMP_RW.ORA" file:

% chmod 600 snmp_rw.ora

  1. Change the DBSNMP password on the database. You can use either Security Manager, Sqlplus, or Server Manager. If you use SQLPlus or Server Manager, you can issue the following command:

SQL> alter user "dbsnmp" identified by "<newpassword>";

  1. Stop and restart the Intelligent Agent.

OUTLN

outln

Oracle8i 이후 추가된 유저로, 옵티마이저의 실행계획을 고정시킬때 사용하는 OUTLINE 기능을 위해 사용된다. OUTLN 유저는 DBA 권한을 갖고 있다.

MDSYS

mdsys

지리 정보 저장을 위한 Oracle Spatial 기능을 위해 추가된 유저. 관련된 테이블, 프로시져등을 접근하고 분석할때 사용된다.

ORDSYS

ordsys

Oracle8i Time Series를 지원하기 위해 추가된 유저. TIMESTAMP 를 지원하는것이 주요 기능으로 Oracle 8i 때 추가되었다.

ORDPLUGINS

ordplugins

Oracle interMedia 기능을 위해 추가된 유저. Oracle interMedia 는 멀티미디어 저장을 위해 만들어진 추가툴이다.

CTXSYS

ctxsys

Oracle ConText Cartridge 기능을 위해 추가된 유저. 이 기능은 대량의 텍스트 정보에서 원하는 서치를 빠르게 해주는 기능이다.

DSSYS

dssys

Dynamic Services Secured Web Service 를 위해 추가된 유저. Dynamic Services supports content access from databases (SQL/PLSQL) as well as Internet applications (HTTP/HTTPS). DS Engine can interpret XML and HTML content along with the result sets returned from database access. DS Engine is integrated with Oracle Portal via a Web Provider mechanism. This integration allows all the services registered with DS Engine to be accessible as portlets.

PERFSTAT

perfstat

Oracle Statistics Package (STATSPACK) 를 지원하기 위한 유저. $ORACLE_HOME/rdbms/admin/spcusr.sql  스크립트로 생성시킨다.

WKPROXY

change_on_install

Oracle's Ultrasearch option 을 위한 유저로Oracle9i 에서 추가되었다. $ORACLE_HOME/ultrasearch/admin/wk0csys.sql  스크립트로 생성시킨다.

WKSYS

change_on_install

Oracle's Ultrasearch option 위한 또다른 유저.

This support account is assigned the following privileges in Oracle9i:

  • CONNECT
  • RESOURCE
  • DBA
  • ALL PRIVILEGES
  • CTXAPP
  • CREATE PUBLIC SYNONYM
  • DROP PUBLIC SYNONYM
  • CREATE ANY VIEW
  • DROP ANY VIEW
  • CREATE ANY TABLE
  • DROP ANY TABLE
  • CREATE ANY INDEX
  • DROP ANY INDEX
  • CREATE ANY SEQUENCE
  • DROP ANY SEQUENCE
  • CREATE ANY TRIGGER
  • DROP ANY TRIGGER
  • JAVAUSERPRIV
  • JAVASYSPRIV
  • SELECT ON SYS.USER$
  • SELECT ON SYS.V_$PARAMETER
  • SELECT ON SYS.GV_$INSTANCE
  • SELECT ON SYS.V_$DATABASE
  • SELECT ON SYS.DBA_CONSTRAINTS
  • SELECT ON SYS.DBA_JOBS
  • SELECT ON SYS.DBA_DB_LINKS
  • SELECT ON SYS.DBA_ROLE_PRIVS
  • SELECT ON SYS.DBA_LOCK
  • SELECT ON SYS.DBMS_LOCK_ALLOCATED
  • SELECT ON SYS.PROCEDURE$
  • SELECT ON SYS.DBA_TABLES
  • SELECT ON SYS.DBA_VIEWS
  • SELECT ON SYS.DBA_TAB_COLUMNS
  • EXECUTE ON SYS.DBMS_LOCK
  • EXECUTE ON SYS.DBMS_PIPE
  • EXECUTE ON SYS.DBMS_REGISTRY

The default tablespace for this user will be "DRSYS" while its temporary tablespace will be "TEMP".

$ORACLE_HOME/ultrasearch/admin/wk0install.sql 로 생성한다

WMSYS

wmsys

Oracle Workspace Manager 에서 필요한 메타데이터를 저장하기 위해 사용되는 유저. Oracle9i 에서 추가되었다.

$ORACLE_HOME/rdbms/admin/owmctab.plb 로 생성한다.

XDB

change_on_install

SQL XML 기능을 위해 사용하는 유저. $ORACLE_HOME/rdbms/admin/catqm.sql  로 생성한다.

ANONYMOUS

...IDENTIFIED BY VALUES 'anonymous'

HTTP 를 통해Oracle XML DB를 접근하기 위해 사용되는 유저. $ORACLE_HOME/rdbms/admin/catqm.sql 로 생성한다.

ODM

odm

Oracle Data Mining 기능을 위해 생성된 유저. oracle9i 에서 추가되었다. $ORACLE_HOME/dm/admin/dmcrt.sql  로 생성한다.

ODM_MTR

mtrpw

Oracle Data Mining 기능을 위해 생성된 유저. oracle9i 에서 추가되었다. $ORACLE_HOME/dm/admin/dmcrt.sql

OLAPSYS

mtrpw

OLAP 메타데이터 저장을 위한 유저. oracle9i 에서 추가되었다. $ORACLE_HOME/dm/admin/dmcrt.sql

TRACESVR

trace

Oracle Trace for OEM in Oracle7 에서 추가됨. Oracle Trace Server 가 설치되어야 한다. Oracle 8 이후 버전에서 없어졌다.

REPADMIN

Managed by DBA when user is created.

Replication 유저. DBA가 수동으로 생성해 주어야 한다. $ORACLE_HOME/ldap/admin/oidrsrms.sql , $ORACLE_HOME/ldap/admin/oidrsms.sql.

 

 

Sample Schemas

유저

디폴트 암호

용도 및 설명

SCOTT

tiger

가장 오래된 오라클 샘플 유저.

ADAMS

 

 

JONES

 

 

CLARK

 

 

BLAKE

 

 

 

Oracle9i Sample Schemas

유저

디폴트 암호

용도 및 설명

HR

hr

Human Resources schema. The Human Resources division tracks information on the company's employees and facilities.

OE

oe

Order Entry schema requires "Oracle Spatial" option. The Order Entry division tracks product inventories and sales of the company's products through various channels.

PM

pm

Product Media schema requires "Oracle JVM" and "Oracle Intermedia" options. The Product Media division maintains descriptions and detailed information on each product sold by the company.

SH

sh

Sales History schema requires "Oracle OLAP Services" set up. The Sales History division tracks business statistics to facilitate business decisions.

QS

qs

Queued Shipping schema The Shipping division manages the shipping of products to customer. The sample company has decided to test the use of messaging to manage its proposed B2B applications.

QS_ES

qs_es

(Eastern Shipping)

QS_WS

qs_ws

(Western Shipping)

QS_OS

qs_os

(Overseas Shipping)

QS_CB

qs_cb

(Customer Billing)

QS_CS

qs_cs

(Customer Service)

QS_ADM

qs_adm

(Administration)

QS_CBADM

qs_cbadm

(Customer Billing Administration)

JSERV Accounts

The three JSERV accounts (AURORA$JIS$UTILITY$, AURORA$ORB$UNAUTHENTICATED and OSE$HTTP$ADMIN) are used internally by Enterprise Java Beans and CORBA Tools and created with randomly-generated passwords 'INVALID_ENCRYPTED_PASSWORD'.

These 3 scripts are launched by init_jis.sql script to install the Oracle Servlet Engine (OSE).

Changing their passwords would prevent the ORB from working. This is supposed to change in a future version so that you can change their password.

유저

디폴트 암호

용도 및 설명

AURORA$ORB$UNAUTHENTICATED

<Random>

Description: Create the public user for the Aurora/ORB. This is the identity any non-validated ORB client will run as. This is the user for users who don't authenticate in the Aurora/ORB

Created By: jisorb.sql

AURORA$JIS$UTILITY$

<Random>

Description: Create the public user for the Aurora/ORB. This is the identity any non-validated ORB client will run as. This is the user for users who don't authenticate in the Aurora/ORB

Created By: jisbgn.sql

OSE$HTTP$ADMIN

<Random>

Description: Create the public user for the Aurora/ORB. This is the identity any non-validated ORB client will run as. This is the user for users who don't authenticate in the Aurora/ORB

Created By: jishausr.sql

 오라클 Q&A 게시판 | 방명록 | Home..

반응형
반응형


오라클을 이관 후에는 컴파일을 일괄적으로 해야할 때가 존재한다...

1. 일괄 컴파일

 

Set heading off      
Set feedback off      
Set pages 1000      
 
 spool obj.sql
 select 'set termout on' from dual;
 select 'set echo on' from dual;      
      
 select 'alter trigger '||owner||'.'||object_name||' compile;'
 from dba_objects
 where status <> 'VALID'
 and object_type='TRIGGER';
     
 select 'alter package '||owner||'.'||object_name||' compile;'      
 from dba_objects      
 where status <> 'VALID'       
 and object_type='PACKAGE';      

 select 'alter package '||owner||'.'||object_name||' compile body;'     
 from dba_objects      
 where status <> 'VALID'       
 and object_type='PACKAGE BODY';

 select 'alter procedure '||owner||'.'||object_name||' compile;'       
 from dba_objects      
 where status <> 'VALID'       
 and object_type='PROCEDURE';      

 select 'alter function '||owner||'.'||object_name||' compile;'
 from dba_objects      
 where status <> 'VALID'
 and object_type='FUNCTION';

 select 'alter view '||owner||'.'||object_name||' compile;'       
 from dba_objects      
 where status <> 'VALID'       
 and object_type='VIEW';       
 
 spool off

[출처] [Oracle] 데이타베이스 한꺼번에 Compile하기|작성자 미친예언자




2. 일괄 컴파일

 host rm -rf comp1.sql comp2.sql
set pages 300
select count(1) as INVALID_OBJECT_COUNT from dba_objects where status !='VALID';
set pages 0
set line 1000
set echo off
set feedback off
set space 0
col compile for a1000
select systimestamp as start_time from dual;
spool comp1.sql
select 'prompt '||object_type||' '||object_name||' compiling'||'
prompt '||'
alter '||object_type||' '||owner||'.'||object_name||' compile;' as compile
from dba_objects
where status !='VALID'
and object_type !='PACKAGE BODY';
spool off
host ls -al comp1.sql
host echo "select systimestamp from dual;" >> comp1.sql
start comp1.sql
show error
spool comp2.sql
select 'prompt '||object_type||' '||object_name||' compiling'||'
prompt '||'
alter package '||owner||'.'||object_name||' compile body;' as compile
from dba_objects
where status !='VALID'
and object_type ='PACKAGE BODY';
spool off
host ls -al comp2.sql
host echo "select systimestamp from dual;" >> comp2.sql
start comp2.sql
show error
set echo on
set feedback on
set pages 3000
set space 1
col owner for a20
col object_name for a28
col object_type for a20
col status for a16
select owner,object_name,object_type,status from dba_objects
where status !='VALID';
select count(1) INVALID_OBJECT_COUNT from dba_objects where status !='VALID';
select systimestamp as end_time from dual;


3. 일괄 컴파일

 1. SQL> @?/rdbms/admin/utlrp.sql

2. utlrp를 parallel하게...
execute utl_recomp.recomp_parallel(4);

3. 만약 ERP라면...위의 두개로 해결이 안될때에는...
cd $AD_TOP/sql/adcompsc를 사용합니다.
adcompsc <== 이게 산타님 말씀하신것 처럼 alter문장을 생성하여 실행합니다.
참고하세요^^

반응형
반응형

고객사에서 아래의 작업이 매 주 일어납니다.

 

1. 운영 DB서버의 컨트롤/리두로그/데이터 파일 부분을 테스트 DB서버로 이미지카피를 합니다.

   (DB 엔진부분이나 설정파일은 복사하지 않습니다.)

2. 테스트 DB의 SID를 테스트에 맞게 변경해줍니다.

 

예전같으면 벌벌떨면서 진행했던 SID 변경 작업이지만,

10.x 이상의 버젼에서 nid라는 도구가 도입되면서 아주 간단한(실수를 하지 않는다면) 작업으로 변했습니다.

 

아래는 변경 절차입니다.

운영 DB서버의 SID는 PROD, 테스트 DB서버의 SID는 TEST라고 하겠습니다.

 

##########################################################################

이미지 카피가 정상적으로 되어 DB가 정상적으로 올라오는지 확인하는 부분

##########################################################################

 

1) 이미지카피가 완료된 후....

 

2) .profile에 설정되어 있는 SID를 PROD로 변경합니다.

 

3) . .profile로 변경된 사항을 적용합니다.

 

4) cp inittest.ora initprod.ora 명령으로 기 존재하는 파라메터 파일을 이용하여 초기화 파라메터 파일을 생성합니다.

 

5) 생성한 initprod.ora 파일을 열어서, controlfile의 위치를 실제 파일이 위치하는 곳으로 변경하고..

   db_name 파라메터를 prod로 변경하고..

   local listener 파라메터 설정 부분을 remark 합니다.

 

6) 패스워드 파일 사용중이라면 orapwd 명령으로 패스워드 파일을 생성합니다. 

 

7) sqlplus 에 로그인하고, startup 명령으로 DB를 살려서 정상적으로 올라오는지 확인합니다.

 

##########################################################################

SID을 바꾸고 DB가 정상적으로 올라오는지 확인하는 부분

##########################################################################

8) DB가 정상이라면 shutdown 명령으로 DB를 내립니다.

 

9) DB를 Mount 단계까지 올립니다.

 

10) 다른 창을 하나 띄워서 아래의 명령어로 SID를 변경합니다.

    nid target=sys/<패스워드> dbname=TEST setname=yes

    (nid가 실행되면 nid가 Mount되어 있는 DB를 shutdown 시킵니다.)

    <실제 수행 화면>

[oracle@sbiztdb1:prod:/sks1/oracle]nid target=sys/<패스워드> dbname=TEST setname=y

DBNEWID: Release 10.2.0.4.0 - Production on Sat Jun 13 22:53:29 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to database PROD (DBID=3426403114)

Connected to server version 10.2.0

Control Files in database:
    /dev/hdvg21/rlvol_0500M0001
    /dev/hdvg22/rlvol_0500M0006
    /dev/hdvg23/rlvol_0500M0011

Change database name of database PROD to TEST? (Y/[N]) => Y

Proceeding with operation
Changing database name from PROD to TEST
    Control File /dev/hdvg21/rlvol_0500M0001 - modified
    Control File /dev/hdvg22/rlvol_0500M0006 - modified
    Control File /dev/hdvg23/rlvol_0500M0011 - modified
    Datafile /dev/hdvg21/rlvol_4000M0001 - wrote new name
    Datafile /dev/hdvg21/rlvol_8000M0002 - wrote new name
    Datafile /dev/hdvg22/rlvol_2000M0008 - wrote new name
    Datafile /dev/hdvg26/rlvol_4000M0042 - wrote new name
    Datafile /dev/hdvg22/rlvol_2000M0009 - wrote new name
    Datafile /dev/hdvg21/rlvol_8000M0003 - wrote new name
    Datafile /dev/hdvg21/rlvol_8000M0004 - wrote new name
    Datafile /dev/hdvg21/rlvol_8000M0005 - wrote new name
    Datafile /dev/hdvg21/rlvol_8000M0006 - wrote new name
    Datafile /dev/hdvg21/rlvol_8000M0007 - wrote new name
    Datafile /dev/hdvg22/rlvol_8000M0008 - wrote new name
    Datafile /dev/hdvg22/rlvol_8000M0009 - wrote new name
    Datafile /dev/hdvg22/rlvol_8000M0011 - wrote new name
    Datafile /dev/hdvg22/rlvol_8000M0012 - wrote new name
    Datafile /dev/hdvg22/rlvol_8000M0013 - wrote new name
    Datafile /dev/hdvg22/rlvol_8000M0014 - wrote new name
    Datafile /dev/hdvg23/rlvol_8000M0015 - wrote new name
    Datafile /dev/hdvg23/rlvol_8000M0016 - wrote new name
    Datafile /dev/hdvg23/rlvol_8000M0017 - wrote new name
    Datafile /dev/hdvg23/rlvol_8000M0018 - wrote new name
    Datafile /dev/hdvg23/rlvol_8000M0019 - wrote new name
    Datafile /dev/hdvg23/rlvol_8000M0020 - wrote new name
    Datafile /dev/hdvg23/rlvol_8000M0021 - wrote new name
    Datafile /dev/hdvg24/rlvol_8000M0022 - wrote new name
    Datafile /dev/hdvg24/rlvol_8000M0023 - wrote new name
    Datafile /dev/hdvg24/rlvol_8000M0024 - wrote new name
    Datafile /dev/hdvg24/rlvol_8000M0025 - wrote new name
    Datafile /dev/hdvg24/rlvol_8000M0026 - wrote new name
    Datafile /dev/hdvg24/rlvol_8000M0027 - wrote new name
    Datafile /dev/hdvg24/rlvol_8000M0028 - wrote new name
    Datafile /dev/hdvg25/rlvol_8000M0030 - wrote new name
    Datafile /dev/hdvg25/rlvol_8000M0031 - wrote new name
    Datafile /dev/hdvg25/rlvol_8000M0032 - wrote new name
    Datafile /dev/hdvg25/rlvol_8000M0034 - wrote new name
    Datafile /dev/hdvg25/rlvol_8000M0035 - wrote new name
    Datafile /dev/hdvg26/rlvol_8000M0036 - wrote new name
    Datafile /dev/hdvg26/rlvol_8000M0037 - wrote new name
    Datafile /dev/hdvg26/rlvol_8000M0038 - wrote new name
    Datafile /dev/hdvg21/rlvol_4000M0002 - wrote new name
    Datafile /dev/hdvg21/rlvol_4000M0003 - wrote new name
    Datafile /dev/hdvg21/rlvol_4000M0004 - wrote new name
    Datafile /dev/hdvg21/rlvol_4000M0005 - wrote new name
    Datafile /dev/hdvg21/rlvol_4000M0007 - wrote new name
    Datafile /dev/hdvg22/rlvol_4000M0008 - wrote new name
    Datafile /dev/hdvg22/rlvol_4000M0009 - wrote new name
    Datafile /dev/hdvg22/rlvol_4000M0010 - wrote new name
    Datafile /dev/hdvg22/rlvol_4000M0011 - wrote new name
    Datafile /dev/hdvg22/rlvol_4000M0013 - wrote new name
    Datafile /dev/hdvg23/rlvol_4000M0015 - wrote new name
    Datafile /dev/hdvg26/rlvol_8000M0040 - wrote new name
    Datafile /dev/hdvg26/rlvol_8000M0041 - wrote new name
    Datafile /dev/hdvg26/rlvol_8000M0042 - wrote new name
    Datafile /dev/hdvg27/rlvol_8000M0043 - wrote new name
    Datafile /dev/hdvg27/rlvol_8000M0044 - wrote new name
    Datafile /dev/hdvg27/rlvol_8000M0045 - wrote new name
    Datafile /dev/hdvg27/rlvol_8000M0047 - wrote new name
    Datafile /dev/hdvg27/rlvol_8000M0049 - wrote new name
    Datafile /dev/hdvg28/rlvol_8000M0050 - wrote new name
    Datafile /dev/hdvg28/rlvol_8000M0051 - wrote new name
    Datafile /dev/hdvg23/rlvol_4000M0017 - wrote new name
    Datafile /dev/hdvg21/rlvol_2000M0001 - wrote new name
    Datafile /dev/hdvg21/rlvol_2000M0003 - wrote new name
    Datafile /dev/hdvg22/rlvol_2000M0010 - wrote new name
    Datafile /dev/hdvg22/rlvol_2000M0012 - wrote new name
    Datafile /dev/hdvg22/rlvol_2000M0014 - wrote new name
    Datafile /dev/hdvg23/rlvol_2000M0016 - wrote new name
    Datafile /dev/hdvg23/rlvol_2000M0018 - wrote new name
    Datafile /dev/hdvg23/rlvol_2000M0019 - wrote new name
    Datafile /dev/hdvg23/rlvol_2000M0020 - wrote new name
    Datafile /dev/hdvg23/rlvol_2000M0021 - wrote new name
    Datafile /dev/hdvg23/rlvol_4000M0019 - wrote new name
    Datafile /dev/hdvg23/rlvol_4000M0020 - wrote new name
    Datafile /dev/hdvg24/rlvol_4000M0022 - wrote new name
    Datafile /dev/hdvg24/rlvol_2000M0022 - wrote new name
    Datafile /dev/hdvg24/rlvol_2000M0023 - wrote new name
    Datafile /dev/hdvg28/rlvol_8000M0054 - wrote new name
    Datafile /dev/hdvg28/rlvol_8000M0053 - wrote new name
    Datafile /dev/hdvg28/rlvol_8000M0055 - wrote new name
    Datafile /dev/hdvg28/rlvol_8000M0056 - wrote new name
    Datafile /dev/hdvg24/rlvol_4000M0023 - wrote new name
    Datafile /dev/hdvg24/rlvol_4000M0024 - wrote new name
    Datafile /dev/hdvg24/rlvol_4000M0026 - wrote new name
    Datafile /dev/hdvg24/rlvol_4000M0027 - wrote new name
    Datafile /dev/hdvg24/rlvol_4000M0028 - wrote new name
    Datafile /dev/hdvg25/rlvol_4000M0029 - wrote new name
    Datafile /dev/hdvg25/rlvol_4000M0030 - wrote new name
    Datafile /dev/hdvg25/rlvol_4000M0031 - wrote new name
    Datafile /dev/hdvg25/rlvol_4000M0033 - wrote new name
    Datafile /dev/hdvg25/rlvol_4000M0034 - wrote new name
    Datafile /dev/hdvg25/rlvol_4000M0035 - wrote new name
    Datafile /dev/hdvg26/rlvol_4000M0036 - wrote new name
    Datafile /dev/hdvg24/rlvol_2000M0024 - wrote new name
    Datafile /dev/hdvg24/rlvol_2000M0025 - wrote new name
    Datafile /dev/hdvg21/rlvol_2000M0005 - wrote new name
    Datafile /dev/hdvg29/rlvol_8000M0058 - wrote new name
    Datafile /dev/hdvg29/rlvol_8000M0059 - wrote new name
    Datafile /dev/hdvg29/rlvol_8000M0060 - wrote new name
    Datafile /dev/hdvg29/rlvol_8000M0061 - wrote new name
    Datafile /dev/hdvg29/rlvol_8000M0062 - wrote new name
    Datafile /dev/hdvg29/rlvol_8000M0063 - wrote new name
    Datafile /dev/hdvg30/rlvol_8000M0064 - wrote new name
    Datafile /dev/hdvg26/rlvol_4000M0038 - wrote new name
    Datafile /dev/hdvg26/rlvol_4000M0039 - wrote new name
    Datafile /dev/hdvg26/rlvol_4000M0040 - wrote new name
    Datafile /dev/hdvg26/rlvol_4000M0041 - wrote new name
    Datafile /dev/hdvg27/rlvol_4000M0047 - wrote new name
    Datafile /dev/hdvg27/rlvol_4000M0048 - wrote new name
    Datafile /dev/hdvg27/rlvol_4000M0049 - wrote new name
    Datafile /dev/hdvg28/rlvol_4000M0050 - wrote new name
    Datafile /dev/hdvg21/rlvol_1000M0001 - wrote new name
    Datafile /dev/hdvg21/rlvol_1000M0002 - wrote new name
    Datafile /dev/hdvg24/rlvol_2000M0026 - wrote new name
    Datafile /dev/hdvg24/rlvol_2000M0027 - wrote new name
    Datafile /dev/hdvg21/rlvol_1000M0003 - wrote new name
    Datafile /dev/hdvg21/rlvol_1000M0004 - wrote new name
    Datafile /dev/hdvg21/rlvol_2000M0006 - wrote new name
    Datafile /dev/hdvg24/rlvol_2000M0028 - wrote new name
    Datafile /dev/hdvg25/rlvol_2000M0029 - wrote new name
    Datafile /dev/hdvg30/rlvol_8000M0066 - wrote new name
    Datafile /dev/hdvg30/rlvol_8000M0067 - wrote new name
    Datafile /dev/hdvg21/rlvol_1000M0005 - wrote new name
    Datafile /dev/hdvg21/rlvol_1000M0006 - wrote new name
    Datafile /dev/hdvg21/rlvol_4000M0006 - wrote new name
    Datafile /dev/hdvg27/rlvol_4000M0044 - wrote new name
    Datafile /dev/hdvg28/rlvol_4000M0052 - wrote new name
    Datafile /dev/hdvg30/rlvol_8000M0069 - wrote new name
    Datafile /dev/hdvg30/rlvol_8000M0070 - wrote new name
    Datafile /dev/hdvg27/rlvol_8000M0048 - wrote new name
    Datafile /dev/hdvg28/rlvol_4000M0054 - wrote new name
    Datafile /dev/hdvg28/rlvol_4000M0055 - wrote new name
    Datafile /dev/hdvg27/rlvol_4000M0043 - wrote new name
    Datafile /dev/hdvg30/rlvol_4000M0070 - wrote new name
    Datafile /dev/hdvg25/rlvol_8000M0033 - wrote new name
    Datafile /dev/hdvg25/rlvol_8000M0029 - wrote new name
    Datafile /dev/hdvg26/rlvol_8000M0039 - wrote new name
    Datafile /dev/hdvg23/rlvol_4000M0018 - wrote new name
    Datafile /dev/hdvg23/rlvol_4000M0021 - wrote new name
    Datafile /dev/hdvg24/rlvol_4000M0025 - wrote new name
    Datafile /dev/hdvg26/rlvol_4000M0037 - wrote new name
    Datafile /dev/hdvg27/rlvol_4000M0045 - wrote new name
    Datafile /dev/hdvg27/rlvol_4000M0046 - wrote new name
    Datafile /dev/hdvg25/rlvol_2000M0030 - wrote new name
    Datafile /dev/hdvg25/rlvol_2000M0032 - wrote new name
    Datafile /dev/hdvg25/rlvol_2000M0033 - wrote new name
    Datafile /dev/hdvg28/rlvol_4000M0056 - wrote new name
    Datafile /dev/hdvg29/rlvol_4000M0057 - wrote new name
    Datafile /dev/hdvg29/rlvol_4000M0058 - wrote new name
    Datafile /dev/hdvg29/rlvol_4000M0059 - wrote new name
    Datafile /dev/hdvg29/rlvol_4000M0060 - wrote new name
    Datafile /dev/hdvg29/rlvol_4000M0061 - wrote new name
    Datafile /dev/hdvg29/rlvol_4000M0062 - wrote new name
    Datafile /dev/hdvg22/rlvol_4000M0012 - wrote new name
    Datafile /dev/hdvg22/rlvol_4000M0014 - wrote new name
    Datafile /dev/hdvg21/rlvol_2000M0002 - wrote new name
    Datafile /dev/hdvg28/rlvol_4000M0051 - wrote new name
    Datafile /dev/hdvg29/rlvol_4000M0063 - wrote new name
    Datafile /dev/hdvg21/rlvol_2000M0004 - wrote new name
    Datafile /dev/hdvg25/rlvol_2000M0034 - wrote new name
    Datafile /dev/hdvg25/rlvol_2000M0035 - wrote new name
    Datafile /dev/hdvg26/rlvol_2000M0036 - wrote new name
    Datafile /dev/hdvg23/rlvol_4000M0016 - wrote new name
    Datafile /dev/hdvg22/rlvol_1000M0007 - wrote new name
    Datafile /dev/hdvg26/rlvol_2000M0037 - wrote new name
    Datafile /dev/hdvg22/rlvol_8000M0010 - wrote new name
    Datafile /dev/hdvg21/rlvol_2000M0007 - wrote new name
    Datafile /dev/hdvg25/rlvol_4000M0032 - wrote new name
    Datafile /dev/hdvg28/rlvol_4000M0053 - wrote new name
    Datafile /dev/hdvg22/rlvol_2000M0011 - wrote new name
    Datafile /dev/hdvg22/rlvol_2000M0013 - wrote new name
    Datafile /dev/hdvg23/rlvol_2000M0015 - wrote new name
    Datafile /dev/hdvg30/rlvol_4000M0064 - wrote new name
    Datafile /dev/hdvg30/rlvol_4000M0065 - wrote new name
    Datafile /dev/hdvg30/rlvol_4000M0066 - wrote new name
    Datafile /dev/hdvg30/rlvol_4000M0067 - wrote new name
    Datafile /dev/hdvg30/rlvol_4000M0069 - wrote new name
    Datafile /dev/hdvg30/rlvol_4000M0068 - wrote new name
    Datafile /dev/hdvg26/rlvol_2000M0038 - wrote new name
    Datafile /dev/hdvg26/rlvol_2000M0039 - wrote new name
    Datafile /dev/hdvg23/rlvol_2000M0017 - wrote new name
    Datafile /dev/hdvg25/rlvol_2000M0031 - wrote new name
    Datafile /dev/hdvg26/rlvol_2000M0040 - wrote new name
    Datafile /dev/hdvg26/rlvol_2000M0041 - wrote new name
    Datafile /dev/hdvg26/rlvol_2000M0042 - wrote new name
    Datafile /dev/hdvg27/rlvol_2000M0043 - wrote new name
    Datafile /dev/hdvg28/rlvol_1000M0044 - wrote new name
    Datafile /dev/hdvg28/rlvol_1000M0045 - wrote new name
    Datafile /dev/hdvg27/rlvol_2000M0044 - wrote new name
    Datafile /dev/hdvg27/rlvol_2000M0045 - wrote new name
    Datafile /dev/hdvg27/rlvol_2000M0046 - wrote new name
    Datafile /dev/hdvg27/rlvol_2000M0047 - wrote new name
    Datafile /dev/hdvg27/rlvol_2000M0048 - wrote new name
    Datafile /dev/hdvg27/rlvol_2000M0049 - wrote new name
    Datafile /dev/hdvg28/rlvol_2000M0050 - wrote new name
    Datafile /dev/hdvg28/rlvol_2000M0051 - wrote new name
    Datafile /dev/hdvg28/rlvol_2000M0052 - wrote new name
    Datafile /dev/hdvg28/rlvol_2000M0053 - wrote new name
    Datafile /dev/hdvg28/rlvol_2000M0054 - wrote new name
    Datafile /dev/hdvg28/rlvol_2000M0055 - wrote new name
    Datafile /dev/hdvg21/rlvol_8000M0001 - wrote new name
    Datafile /dev/hdvg27/rlvol_8000M0046 - wrote new name
    Datafile /dev/hdvg28/rlvol_8000M0052 - wrote new name
    Datafile /dev/hdvg29/rlvol_8000M0057 - wrote new name
    Datafile /dev/hdvg30/rlvol_8000M0065 - wrote new name
    Datafile /dev/hdvg30/rlvol_8000M0068 - wrote new name
    Control File /dev/hdvg21/rlvol_0500M0001 - wrote new name
    Control File /dev/hdvg22/rlvol_0500M0006 - wrote new name
    Control File /dev/hdvg23/rlvol_0500M0011 - wrote new name
    Instance shut down

Database name changed to TEST.
Modify parameter file and generate a new password file before restarting.
Succesfully changed database name.
DBNEWID - Completed succesfully.

 

11) .profile에 설정되어 있는 SID를 TEST로 변경합니다.   

 

12) sqlplus 에 로그인하고, startup 명령으로 DB를 살려서 정상적으로 올라오는지 확인합니다.

    (pfile을 가지고 spfile을 생성한 후 다시 startup하여 spfile로 DB가 운영되도록 수정합니다.)

   SQL>startup pfile=inittbizdb.ora
   SQL>create spfile from pfile;
   SQL>shutdown immediate
   SQL>startup

 

13) 아무런 문제가 없다면 작업 종료...

 

일반적으로 SID만 변경하시는 분들은 8)부터만 수행하시면 됩니다. 1)~7)까지는 이미지카피 후 정합성 확인하는 부분입니다.

 

좀 더 자세한 내용은 nid로 오라클 사이트에서 검색하시면 찾으실 수 있을 겁니다....

 

업무에 도움이 되셨길 빕니다....^^

반응형

'Database > ORACLE' 카테고리의 다른 글

Oradebug 사용법  (0) 2010.03.26
ErrorStack 덤프를 이용해 문제 SQL 찾아내기  (0) 2010.03.26
Oracle SID error  (0) 2010.02.09
rman Tool  (0) 2010.02.01
WS1-2-ch18. Data Pump (expdp/impdp) overview  (0) 2010.02.01
반응형

복구 관리자 (recovery manager:rman)는 데이터베이스의 백업과 복구에 관련된 정보를 저장하고 필요한 경우 백업과 복구 절차를 수행해 주는 유틸리티이다. 데이터베이스, 테이블스페이스, 데이터파일, 컨트롤 파일, 아카이브 파일별로 백업할 수 있으며, 백업 시 사용되지 않는 블록을 제외하고 백업할 수 도 있다. 또한 백업 시 손상된 블록의 사용 가능 여부를 확인해 주기도 한다.

rman 툴은 자체적인 스크립트 해석 인터프리터를 가진 명령언어 인터프리터(command language interpreter)이므로 입력된 명령을 해석하여 실행하게 된다. 예를 들어, backup, restore, copy, recover와 같은 명령을 rman 툴에서 실행할 수 있는 것이다.

rman의 형식은 다음과 같다.

형식

RMAN  [TARGET connectStringSpec
      ¦ { CATALOG connectStringSpec }
      ¦ LOG ['] filename ['] [APPEND ]
      ......
      ]...
      
connectStringSpec::=
  ['] [userid] [/ [password]] [@net_service_name] ['] 




rman 구성

RMAN 시작과 DB에 연결
다음 예제는 간단하게 rman에 접속하고 접속해지 하는 과정이다.
【예제】 ☜ rman 시각과 끝
$ rman

RMAN> exit

$ 
SQL*Plus로 데이터베이스에 접속하듯이 RMAN으로도 데이터베이스에 접속하는데,
그 차이점은 RMAN은 SYSDBA 권한을 가지고 타킷과 보조 데이터베이스에 접속해야 하는데 AS SYSDBA 키워드는 사용하지 않아도 묵시적으로 가진 것으로 간주하기 때문에 의도적으로 표시하지 않아도 된다는 점만 다르다.

RMAN에 연결되면 CONNECT TARGET을 실행해야 타킷 데이터베이스에 접속이 이루어진다.

【예제】☜ target DB에 관리자로 접속 
$ rman

RMAN> connect target /

connected to target database: ORCL (DBID=1204356616)

RMAN> exit

Recovery Manager complete.
$
다음 예는 RMAN 세션중에 출력되는 텍스트 파일을 로그 파일(/tmp/msglog.log)에 추가하도록 하는 예제이다.
【예제】☜ log 파일을 지정하면서 접속 
$ rman TARGET / LOG /tmp/msglog.log APPEND
RMAN> exit
$
이처럼 rman 툴을 이용하여 rman 클라이언트로 들어간 다음에, rman> 프롬프트에서 입력되는 명령은 그 문장의 끝에 세미콜론(;)을 붙여야 하는데, 다만 예외로 STARTUP, SHUTDOWN, CONNECT 명령은 세미콜론을 붙여도 되고 안 붙여도 된다

【예제】

RMAN> CONNECT TARGET
RMAN> BACKUP DATABASE;

RMAN> BACKUP DATABASE
2>  INCLUDE CURRENT
3>  CONTROLFILE
4>  ;
디폴트 RMAN configuration 보기

RMAN이 백업과 복구를 실행하는 구성을 미리 작성한 디폴트 configure가 준비되어 적용된다.
configure란 백업장치를 지정하고, 백업 장치에 접속(이를 channel이라 부름)의 구성을 설정하는 것이다.
현재 작성된 configure를 다음과 같이 확인할 수 있다.

1) RMAN을 시작하고 타킷 DB에 접속한다.
$ rman TARGET /

2) SHOW ALL 명령을 실행한다.
RMAN> SHOW ALL;


$ rman TARGET /
RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BZIP2'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/export/home/oracle/app/oracle/product/110.1/dbs/snapcf_orcl.f'; # default

RMAN> 

나열되는 항목은 CONFIGURE 명령으로 재작성할 수 있으며, 다음은 channel를 configure하는 예시이다.

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # backup goes to disk
CONFIGURE DEVICE TYPE sbt PARALLELISM 2; # 2 channels used in in channel
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/disk1/%U' # 1st channel to disk1
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/disk2/%U' # 2nd channel to disk2
BACKUP DATABASE; # backup - 1st channel goes to disk1 and 2nd to disk2

데이터베이스 백업

BACKUP 명령으로 파일을 백업한다. RMAN은 configure로 설정된 장치에 데이터를 백업하는데, 디폴트는 disk이다.
flash recovery가 가능하고 FORMAT 매개변수를 지정하지 않은 경우라면, RMAN은 recovery 영역에 unique한 이름으로 자동적으로 백업을 생성한다.
RMAN은 디폴트로 image copy보다는 백업 셋을 생성하는데, 여기서 image copy란 유닉스의 cp 명령어로 복사하는 것을 image copy 라 한다.
backup set은 하나 이상의 backup piece로 RMAN으로만 억세스할 수 있도록 물리적 파일을 복사하는 것을 뜻한다.

BACKUP AS COPY 명령은 데이터베이스 파일을 디스크에 bit-for-bit로 image copy를 수행하는데 이는 RMAN에서만 이용할 수 있다.

option 예제 설명
FORMAT
BACKUP
 FORMAT 'AL_%d/%t/%s/%p'
 ARCHIVELOG LIKE '%arc_dest%';
백업할 조각의 위치와 이름을 지정함
%U : 유일한 이름
%d : DB_NAME
%t : timestamp를 가짐
%s : number를 가짐
%p : backup piece number
TAG
BACKUP
 TAG 'weekly_full_db-bkup'
 DATABASE MAXSETSIZE 10M;
백업 라벨에 사용자 정의 문자로 지정하지만,
TAG을 지정하지 않으면 date와 time이 디촐트임

【예제】☜ 데이터베이스를 백업

ARCHIVELOG 모드
1) RMAN을 시작하고 타킷 DB에 접속한다.
$ rman TARGET / 2) BACKUP DATABASE 명령을 실행한다.
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;
NOARCHIVELOG 모드
데이터베이스는 반드시 mount 상태이어야 한다.

1) RMAN을 시작하고 타킷 DB에 접속한다.
$ rman TARGET / 2) shutdown하고 mount한다.
RMAN> SHUTDOWN IMMEDIATE
RMAN> STARTUP FORCE DBA;
RMAN> SHUTDOWN IMMEDIATE
RMAN> STARTUP MOUNT; 3) BACKUP DATABASE를 실행한다.(아래 둘 중 하나)
RMAN> BACKUP DATABASE;
RMAN> BACKUP AS COPY DATABASE; 4) 데이터베이스를 open한다.
RMAN> ALTER DATABASE OPEN;

앞 예제에서와 같이 archive mode와 noarchive mode을 예제로 익혔다.

incremental backup

incremental backup은 BACKUP INCREMENTAL 명령을 사용하여 실행하는데, 이는 full database backup보다 더 빠르다.
그러므로 recovery도 redo logs만 사용하는 경우보다 더 신속하게 복구할 수 있다.
incremental backup이나 full backup 모두 level 0의 내용은 동일하지만, full backup과 달리 level 0 backup은 incremental backup에 관한 사항이 담겨있다.
level 1 incremental backup은 이전의 incremental backup 이후의 변경된 내용만 담긴다.
그래서 level 1 백업을 cumulative incremental backup이라하고, level 0 백업을 differential incremental backup이라하는데, differential이 디폴트이다.

【예제】☜ 데이터베이스의 incremental 백업
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) BACKUP INCREMENTAL 명령을 실행한다.
다음은 level 0 incremental 백업인 경우

RMAN> BACKUP INCREMENTAL LEVEL 0 DATABASE;

다음은 level 1 cumulative incremental 백업인 경우

RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;

다음은 level 1 differential incremental 백업인 경우

RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE;

incrementally updated backup

incrementally updated 백업은 BACKUP FOR RECOVER OF COPY 명령을 사용한다.
FOR RECOVER OF COPY 문의 옵션은 다음과 같다.

option 예제
FOR RECOVER OF COPY WITH TAG 'tag_name' BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE;
FOR RECOVER OF COPY DATAFILECOPY FORMAT 'format' BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY DATAFILECOPY FORMAT 'disk2/df1.cpy' DATABASE;

【예제】☜ 데이터베이스의 incrementally updated 백업
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) RECOVER COPY와 BACKUP INCREMENTAL 명령을 실행한다.
다음 스크립트를 실행한다.


     RECOVER COPY OF DATABASE
       WITH TAG 'incr_update';
     BACKUP
       INCREMENTAL LEVEL 1
       FOR RECOVER OF COPY WITH TAG 'incr_update'
       DATABASE;

database 파일과 백업의 validating

VALIDATE 명령을 사용하여 모든 데이터베이스 파일이 존재를 확인하고, 바른 위치에 있는지 확인하며, 또한 물리적 오류의 여지를 확인한다.
CHECK LOGICAL옵션을 사용하여 논리적 오류도 확인할 수 있다.

【예제】☜ 데이터베이스 파일의 유효성 확인
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) VALIDATE 명령을 해당파일에 실행한다.

   BACKUP VALIDATE CHECK LOGICAL
     DATABASE ARCHIVELOG ALL;
만약 각각의 블럭에 대한 유효성 체크는 다음과 같이 할 수 있다.

VALIDATE DATAFILE 4 BLOCK 10 TO 13;

다음은 백업셋에 대한 유효성 체크의 예이며, 백업셋은 LIST BACKUP를 실행하여 확인할 수 있다.

VALIDATE BACKUPSET 3;

RMAN에 동작하는 명령어로 구성된 파일

데이터베이스를 주기적으로 반복하여 백업한다는 것은 실증하기 때문에 이러한 동작을 RMAN 명령으로 작성한 명령 파일을 하나의 스크립트로 작성하여 @아규먼트와 파일이름을 지정하여 실행 시키면 편리하다.

【예제】☜ RMAN에서 동작할 스크립트 생성과 실행
1) vi와 같은 문서편집기로 RMAN 명령문으로 구성된 파일을 작성한다.


    #my_commnad_file.txt
    BACKUP DATABASE PLUS ARCHIVELOG;
    LIST BACKUP;
    EXIT;

2) RMAN을 구동하고 작성한 스크립트를 @ 아규먼트로 실행시킨다.

구 분 명령어 실행 실행 결과
방법1 $ rman TARGET / @my_command_file.txt 실행이 완료되면 RMAN에서 exit함
방법2 RMAN> @my_command_file.txt **end-of-file** 메시지가 출력되며 RMAN에서 exit하지 않음

작성되는 명령문 스크립트에서 비실행문은 #으로 시작되고 또한 중간에 #을 넣으면 #이하는 비실행으로 처리한다.
rman 프롬프트에서 명령을 입력할 때도 #이하는 비실행문으로 처리한다

【예제】☜
RMAN> BACKUP # 이 부분부터 줄 끝까지는 비실행임
2> SPFILE;

Starting backup at 04-JAN-10
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 04-JAN-10
channel ORA_DISK_1: finished piece 1 at 04-JAN-10
piece handle=/export/home/oracle/flash_recovery_area/ORCL/backupset/2010_01_04/o1_mf_nnsnf_TAG20100104T130430_5n2t6gt7_.bkp tag=TAG20100104T130430 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 04-JAN-10

RMAN>

RMAN 동작의 레포트

RMAN의 LISTREPORT 문을 사용하여 RMAN을 사용한 백업 상태에 대한 정보를 알 수 있고, SHOW ALL 문을 사용하여 configuration에 대한 정보를 확인할 수 있다.

백업정보 list

LIST BACKUPLIST COPY 문을 사용하여 백업과 데이터파일에 대한 정보를 나타낸다.
다음 표는 백업에 대한 LIST 문의 옵션이다.

option 예제 설명
BY BACKUP LIST BACKUP OF DATABASE BY BACKUP 백업셋의 출력으로 디폴트임
BY FILE LIST BACKUP BY FILE 백업된 파일에 대한 정보
SUMMARY LIST BACKUP SUMMARY 요약이 출력되는데 디폴트이며 출력은 VERBOSE임
EXPIRED LIST EXPIRED COPY RMAN에의 해 기록된 백업에 관한 목록이지만, 최근 CROSSCHECK 문에 의한 것은 제외함
RECOVERABLE LIST BACKUP RECOVERABLE AVAILABLE 상태에 있는 datafile이 backup, copy된 사항이 나열됨

【예제】☜ LIST BACKUP/COPY 실행
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) LIST 문을 실행한다.

RMAN> LIST BACKUP OF DATABASE;
RMAN> LIST COPY OF DATAFILE 1,2;
RMAN> LIST BACKUP OF ARCHIVELOG FROM SEQUENCE 10;
RMAN> LIST BACKUPSET OF DATAFILE;

데이터베이스 파일과 백업에 관한 REPORT

REPORT 문을 실행하여 LIST 문보다 더 다양한 정보를 알 수 있다.
다음은 REPORT 문의 옵션이다.

option 예제 설명
NEED BACKUP REPORT NEED BACKUP DATABASE 백업해야할 파일을 보임, 추가적으로 REDUNDANCY, RECOVERY WINDOW 를 사용할 수 있음
OBSOLETE REPORT OBSOLETE backup retention policy로 구성된 쓸모없는(폐기된) 백업을 나열함
SCHEMA REPORT SCHEMA 데이터베이스 내의 테이블스페이스와 데이터파일을 출력
UNRECOVERABLE REPORT UNRECOVERABLE 최근의 데이터파일 백업에서 복구될수 없는 데이터파일을 출력

【예제】☜
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) REPORT 문을 실행한다.

RMAN> REPORT SCHEMA;
RMAN> REPORT OBSOLETE;

RMAN 백업 Maintaining

타킷 데이터베이스의 control 파일에 저장된 RMAN의 정보가 RMAN maintence command에 의해 사용된다.

Crosschecking backup

CROSSCHECK 명령에 의해 RMAN에 의해 백업된 논리적 기록물과 저장매체에 있는 파일을 동기화한다.

【예제】☜ crosscheck all backups & copies on disk
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) CROSSCHECK 문을 실행한다.

RMAN> CROSSCHECK BACKUP;
RMAN> CROSSCHECK COPY;

Delete Obsolete Backups

DELETE 명령으로 RMAN으로 디스크나 테이프에 백업하였지만 쓸모없는 백업이나 파일을 삭제하게 된다.

control 파일의 파일 상태를 DELETED로 갱신하고, NOPROMPT를 지정하지 않으면 삭제할 때 의지를 묻게된다.
DELETE OBSOLETE 명령은 더 이상 필요없는 백업이나 복사된 파일을 지울 때 사용된다.

【예제】☜ delete obsolete backups & copies
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) DELETE OBSOLETE 문을 실행한다.

RMAN> DELETE OBSOLETE;

Diagnosing & Repairing Failures with Data Recovery Advisor

data recovery advisor를 이용하여 간단하게 데이터베이스의 문제점을 진단하고 수리할 수 있다.

Listing Failures & Determing Repair Options

Failure란 데이터의 오염(corruption)을 의미한다. failure에는 fail priorityfailure status가 있는데, priority에는 CRITICAL, HIGH, LOW가 있으며, 상태는 OPEN이나 CLOSED일 수 있다.

LIST FAILURE : 모든 종류의 failure를 출력
ADVISE FAILURE : repair option으로 수동과 자동을 결정

【예제】☜ LIST FAILURE & ADVISE FAILURE
RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

RMAN> LIST FAILURE;
RMAN> ADVISE FAILURE;

Repairing Failures

앞의 LIST FAILURE나 ADVISE FAILURE를 실행하고 나서 REPAIR FAILURE 명령으로 수리할 수 있다.

【예제】☜ REPAIR FAILURE
RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

RMAN> REPAIR FAILURE;

Flashback Database

데이터베이스를 과거 어느 시점으로 되돌리는 것으로 이는 미디어 복구와 달리데이터파일을 restore할 필요가 없다.
FLASHBACK DATABASE 명령을 사용하면 과거 어느 시점으로 되돌릴 수 있는데, 이 기능은 반드시 데이터베이스가 mount 되어 있어야 한다.

【예제】☜ Flashback database
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) 데이터베이스가 mount 되어 있어야 한다.

RMAN> SHUTDOWN IMMEDIATE;
RMAN> STARTUP MOUNT;

3) FLASHBACK DATABASE를 다음중 하나를 실행한다.


SQL> select name,scn, time, database_incarnation#,
  2  guarantee_flashback_database
  3  from v$restore_point
  4  where guarantee_flashback_database='YES';

RMAN> FLASHBACK DATABASE TO SCN 86115;
RMAN> FLASHBACK DATABASE TO RESTORE POINT BEFORE_CHANGE;
RMAN> FLASHBACK DATABASE TO TIME "TO_DATE('11/20/10','MM/DD/YY')";

4) 데이터베이스를 SQL*Plus에서 검증하기 위해 open한다.

RMAN> SQL "ALTER DATABASE OPEN READ ONLY";

5) 데이터베이스를 open한다.

RMAN> SHUTDOWN IMMEDIATE;
RMAN> STARTUP MOUNT;
RMAN> ALTER DATABASE OPEN RESETLOGS;

Restore & Recover Database Files

RESTORE나 RECOVER 명령으로 데이터베이스 파일을 복구할 수 있다.

데이터베이스 파일 복구 준비

RESTORE ... PREVIEW 명령으로 사전에 미리보기를 하지만 RESTORE는 실행되지 않는다.

【예제】☜ Preview a database restore & recovery
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) 필요한 경우라면 테이블스페이스와 데이터파일을 확인한다.

RMAN> REPORT SCHEMA;

3) RESTORE DATABASE 명령에 PREVIEW 옵션을 실행한다.

RMAN> RESTORE DATABASE PREVIEW SUMMARY;

데이터베이스 전체를 recover

RESTORE DATABASE와 RECOVER DATABASE 명령을 사용하여 데이터베이스 전체를 복구할 수 있다.

【예제】☜ Recover whole database
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) 파일 복구 준비를 실행한다.

RMAN> RESTORE DATABASE PREVIEW SUMMARY;

3) 데이터베이스를 mount 상태로 만든다.

RMAN> STARTUP FORCE MOUNT;

4) 데이터베이스를 restore한다.

RMAN> RESTORE DATABASE;

5) 데이터베이스를 recover한다.

RMAN> RECOVER DATABASE;

6) 데이터베이스를 open한다.

RMAN> ALTER DATABASE OPEN;

테이블스페이스만 recover

RESTORE TABLESPACE와 RECOVER TABLESPACE 명령을 사용하여 필요한 테이블스페이스만 복구할 수 있다.
데이터파일을 새 위치에 restore할 수 없다면, SET NEWNAME 명령을 RUN하고 SWITCH DATAFILE 명령이나 또는 ALTER DATABASE RENAME FILE 문으로 control file을 갱신할 수 있다.

【예제】☜ Recover tablespace when the database is open
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) 파일 복구 준비를 실행한다.

RMAN> RESTORE DATABASE PREVIEW SUMMARY;

3) OFFLINE 복구를 준비한다.(예: 테이블스페이스 이름::=users)

RMAN> SQL 'ALTER TABLESPACE users OFFLINE';

4) 테이블스페이스를 restore와 recover 한다.

RMAN>

     RUN 
        {
         SET NEWNAME FOR DATAFILE '/disk1/oradata/prod/users01.dbf'
           TO '/disk2/users01.dbf';
         RESTORE TABLESPACE users;
         SWITCH DATAFILE ALL;
         RECOVER TABLESPACE users;
        }

5) 테이블스페이스를 ONLINE한다.

RMAN> SQL 'ALTER TABLESPACE users ONLINE';

이 방법외에 RESTORE DATAFILERECOVER DATAFILE을 사용하여 데이터파일 레벨로 복구할 수 도 있다.

데이터 블럭(block)별로 recover

잘못된 데이터파일 블럭 단위로 복구도 가능한데, v$database_block_corruption 뷰에서 오류된 데이터 파일 블럭을 확인할 수 있다.

【예제】☜ Recover data blocks
1) SQLPlus에서 오류된 데이터블럭 번호를 확인한다.

SQL> SELECT NAME, VALUE FROM V$DIAG_INFO

2) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

3) RECOVER 명령을 실행하여 블럭을 수리한다.

RMAN> RECOVER CORRUPTION LIST;

개별 블럭을 수리하려면 다음과 같이 실행한다.

RMAN> RECOVER DATAFILE 1 BLOCK 233, 235 DATAFILE 2 BLOCK 100 TO 200;


출처 : http://radiocom.kunsan.ac.kr/lecture/oracle/backup_restore/rman.html

반응형
반응형

출처 : 오라클 사이트

http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9013.htm#SQLRF01603

GRANT

Purpose

Use the GRANT statement to grant:

  • System privileges to users and roles.

  • Roles to users and roles. Both privileges and roles are either local, global, or external. Table 18-1 lists the system privileges (organized by the database object operated upon). Table 18-2 lists Oracle Database predefined roles.

  • Object privileges for a particular object to users, roles, and PUBLIC. Table 18-3 summarizes the object privileges that you can grant on each type of object. Table 18-4 lists object privileges and the operations that they authorize.

Notes on Authorizing Database Users You can authorize database users through means other than the database and the GRANT statement.

  • Many Oracle Database privileges are granted through supplied PL/SQL and Java packages. For information on those privileges, please refer to the documentation for the appropriate package.

  • Some operating systems have facilities that let you grant roles to Oracle Database users with the initialization parameter OS_ROLES. If you choose to grant roles to users through operating system facilities, then you cannot also grant roles to users with the GRANT statement, although you can use the GRANT statement to grant system privileges to users and system privileges and roles to other roles.

See Also:

Additional Topics

Prerequisites

To grant a system privilege, you must either have been granted the system privilege with the ADMIN OPTION or have been granted the GRANT ANY PRIVILEGE system privilege.

To grant a role, you must either have been granted the role with the ADMIN OPTION or have been granted the GRANT ANY ROLE system privilege, or you must have created the role.

To grant an object privilege, you must own the object, or the owner of the object must have granted you the object privileges with the GRANT OPTION, or you must have been granted the GRANT ANY OBJECT PRIVILEGE system privilege. If you have the GRANT ANY OBJECT PRIVILEGE, then you can grant the object privilege only if the object owner could have granted the same object privilege. In this case, the GRANTOR column of the DBA_TAB_PRIVS view displays the object owner rather than the user who issued the GRANT statement.

Syntax

grant::=

Description of grant.gif follows
Description of the illustration grant.gif

(grant_system_privileges::=, grant_object_privileges::=)

grant_system_privileges::=

Description of grant_system_privileges.gif follows
Description of the illustration grant_system_privileges.gif

(grantee_clause ::=)

grant_object_privileges::=

Description of grant_object_privileges.gif follows
Description of the illustration grant_object_privileges.gif

(on_object_clause ::=, grantee_clause ::=)

on_object_clause ::=

Description of on_object_clause.gif follows
Description of the illustration on_object_clause.gif

grantee_clause ::=

Description of grantee_clause.gif follows
Description of the illustration grantee_clause.gif

Semantics

grant_system_privileges

Use these clauses to grant system privileges.

system_privilege

Specify the system privilege you want to grant. Table 18-1 lists the system privileges, organized by the database object operated upon.

  • If you grant a privilege to a user, then the database adds the privilege to the user's privilege domain. The user can immediately exercise the privilege.

  • If you grant a privilege to a role, then the database adds the privilege to the privilege domain of the role. Users who have been granted and have enabled the role can immediately exercise the privilege. Other users who have been granted the role can enable the role and exercise the privilege.

  • If you grant a privilege to PUBLIC, then the database adds the privilege to the privilege domains of each user. All users can immediately perform operations authorized by the privilege.

Oracle Database provides the ALL PRIVILEGES shortcut for granting all the system privileges listed in Table 18-1, except the SELECT ANY DICTIONARY privilege.

role

Specify the role you want to grant. You can grant an Oracle Database predefined role or a user-defined role. Table 18-2 lists the predefined roles.

  • If you grant a role to a user, then the database makes the role available to the user. The user can immediately enable the role and exercise the privileges in the privilege domain of the role.

  • If you grant a role to another role, then the database adds the privilege domain of the granted role to the privilege domain of the grantee role. Users who have been granted the grantee role can enable it and exercise the privileges in the granted role's privilege domain.

  • If you grant a role to PUBLIC, then the database makes the role available to all users. All users can immediately enable the role and exercise the privileges in the privilege domain of the role.

    See Also:

    "Granting a Role to a Role: Example" and CREATE ROLE for information on creating a user-defined role

IDENTIFIED BY Clause

Use the IDENTIFIED BY clause to specifically identify an existing user by password or to create a nonexistent user. This clause is not valid if the grantee is a role or PUBLIC. If the user specified in the grantee_clause does not exist, then the database creates the user with the password and with the privileges and roles specified in this clause.

See Also:

CREATE USER for restrictions on usernames and passwords

WITH ADMIN OPTION

Specify WITH ADMIN OPTION to enable the grantee to:

  • Grant the role to another user or role, unless the role is a GLOBAL role

  • Revoke the role from another user or role

  • Alter the role to change the authorization needed to access it

  • Drop the role

If you grant a system privilege or role to a user without specifying WITH ADMIN OPTION, and then subsequently grant the privilege or role to the user WITH ADMIN OPTION, then the user has the ADMIN OPTION on the privilege or role.

To revoke the ADMIN OPTION on a system privilege or role from a user, you must revoke the privilege or role from the user altogether and then grant the privilege or role to the user without the ADMIN OPTION.

grantee_clause

TO grantee_clause identifies users or roles to which the system privilege, role, or object privilege is granted.

Restriction on Grantees A user, role, or PUBLIC cannot appear more than once in TO grantee_clause.

PUBLIC Specify PUBLIC to grant the privileges to all users.

Restrictions on Granting System Privileges and Roles Privileges and roles are subject to the following restrictions:

  • A privilege or role cannot appear more than once in the list of privileges and roles to be granted.

  • You cannot grant a role to itself.

  • You cannot grant a role IDENTIFIED GLOBALLY to anything.

  • You cannot grant a role IDENTIFIED EXTERNALLY to a global user or global role.

  • You cannot grant roles circularly. For example, if you grant the role banker to the role teller, then you cannot subsequently grant teller to banker.

grant_object_privileges

Use these clauses to grant object privileges.

object_privilege

Specify the object privilege you want to grant. You can specify any of the values shown in Table 18-3. See also Table 18-4.

Restriction on Object Privileges A privilege cannot appear more than once in the list of privileges to be granted.

ALL [PRIVILEGES]

Specify ALL to grant all the privileges for the object that you have been granted with the GRANT OPTION. The user who owns the schema containing an object automatically has all privileges on the object with the GRANT OPTION. The keyword PRIVILEGES is provided for semantic clarity and is optional.

column

Specify the table or view column on which privileges are to be granted. You can specify columns only when granting the INSERT, REFERENCES, or UPDATE privilege. If you do not list columns, then the grantee has the specified privilege on all columns in the table or view.

For information on existing column object grants, query the USER_, ALL_, or DBA_COL_PRIVS data dictionary view.

on_object_clause

The on_object_clause identifies the object on which the privileges are granted. Directory schema objects and Java source and resource schema objects are identified separately because they reside in separate namespaces.

If you can make this grant only because you have the GRANT ANY OBJECT PRIVILEGE system privilege--that is, you are not the owner of object, nor do you have object_privilege on object WITH GRANT OPTION--then the effect of this grant is that you are acting on behalf of the object owner. The *_TAB_PRIVS data dictionary views will reflect that this grant was made by the owner of object.

See Also:

WITH GRANT OPTION

Specify WITH GRANT OPTION to enable the grantee to grant the object privileges to other users and roles.

Restriction on Granting WITH GRANT OPTION You can specify WITH GRANT OPTION only when granting to a user or to PUBLIC, not when granting to a role.

WITH HIERARCHY OPTION

Specify WITH HIERARCHY OPTION to grant the specified object privilege on all subobjects of object, such as subviews created under a view, including subobjects created subsequent to this statement.

This clause is meaningful only in combination with the SELECT object privilege.

object Specify the schema object on which the privileges are to be granted. If you do not qualify object with schema, then the database assumes the object is in your own schema. The object can be one of the following types:

  • Table, view, or materialized view

  • Sequence

  • Procedure, function, or package

  • User-defined type

  • Synonym for any of the preceding items

  • Directory, library, operator, or indextype

  • Java source, class, or resource

You cannot grant privileges directly to a single partition of a partitioned table.

DIRECTORY directory_name Specify a directory schema object on which privileges are to be granted. You cannot qualify directory_name with a schema name.

JAVA SOURCE | RESOURCE The JAVA clause lets you specify a Java source or resource schema object on which privileges are to be granted.

See Also:

CREATE JAVA

Listings of System and Object Privileges

Note:

When you grant a privilege on ANY object, such as CREATE ANY CLUSTER, the result is determined by the value of the O7_DICTIONARY_ACCESSIBILITY initialization parameter. By default, this parameter is set to FALSE, so that ANY privileges give the grantee access to that type of object in all schemas except the SYS schema. If you set O7_DICTIONARY_ACCESSIBILITY to TRUE, then the ANY privileges also give the grantee access, in the SYS schema, to all objects except Oracle Scheduler objects. For security reasons, Oracle recommends that you use this setting only with great caution.

Table 18-1 System Privileges

System Privilege Name Operations Authorized

Advisor Framework Privileges: All of the advisor framework privileges are part of the DBA role.

--

ADVISOR

Access the advisor framework through PL/SQL packages such as DBMS_ADVISOR and DBMS_SQLTUNE.

Please refer to PL/SQL Packages and Types Reference for information on these packages.

ADMINISTER SQL TUNING SET

Create, drop, select (read), load (write), and delete a SQL tuning set owned by the grantee through the DBMS_SQLTUNE package.

ADMINISTER ANY SQL TUNING SET

Create, drop, select (read), load (write), and delete a SQL tuning set owned by any user through the DBMS_SQLTUNE package.

CREATE ANY SQL PROFILE

Accept a SQL Profile recommended by the SQL Tuning Advisor, which is accessed through Enterprise Manager or by the DBMS_SQLTUNE package.

DROP ANY SQL PROFILE

Drop an existing SQL Profile.

ALTER ANY SQL PROFILE

Alter the attributes of an existing SQL Profile.

CLUSTERS:

--

CREATE CLUSTER

Create clusters in the grantee's schema.

CREATE ANY CLUSTER

Create a cluster in any schema. Behaves similarly to CREATE ANY TABLE.

ALTER ANY CLUSTER

Alter clusters in any schema.

DROP ANY CLUSTER

Drop clusters in any schema.

CONTEXTS:

--

CREATE ANY CONTEXT

Create any context namespace.

DROP ANY CONTEXT

Drop any context namespace.

DATABASE:

--

ALTER DATABASE

Alter the database.

ALTER SYSTEM

Issue ALTER SYSTEM statements.

AUDIT SYSTEM

Issue AUDIT statements.

DATABASE LINKS:

--

CREATE DATABASE LINK

Create private database links in the grantee's schema.

CREATE PUBLIC DATABASE LINK

Create public database links.

DROP PUBLIC DATABASE LINK

Drop public database links.

DEBUGGING:

--

DEBUG CONNECT SESSION

Connect the current session to a debugger.

DEBUG ANY PROCEDURE

Debug all PL/SQL and Java code in any database object. Display information on all SQL statements executed by the application.

Note: Granting this privilege is equivalent to granting the DEBUG object privilege on all applicable objects in the database.

DIMENSIONS:

--

CREATE DIMENSION

Create dimensions in the grantee's schema.

CREATE ANY DIMENSION

Create dimensions in any schema.

ALTER ANY DIMENSION

Alter dimensions in any schema.

DROP ANY DIMENSION

Drop dimensions in any schema.

DIRECTORIES:

--

CREATE ANY DIRECTORY

Create directory database objects.

DROP ANY DIRECTORY

Drop directory database objects.

INDEXTYPES:

--

CREATE INDEXTYPE

Create an indextype in the grantee's schema.

CREATE ANY INDEXTYPE

Create an indextype in any schema and create a comment on an indextype in any schema.

ALTER ANY INDEXTYPE

Modify indextypes in any schema.

DROP ANY INDEXTYPE

Drop an indextype in any schema.

EXECUTE ANY INDEXTYPE

Reference an indextype in any schema.

INDEXES:

--

CREATE ANY INDEX

Create in any schema a domain index or an index on any table in any schema.

ALTER ANY INDEX

Alter indexes in any schema.

DROP ANY INDEX

Drop indexes in any schema.

JOB SCHEDULER OBJECTS:

The following privileges are needed to execute procedures in the DBMS_SCHEDULER package.

CREATE JOB

Create jobs, schedules, or programs in the grantee's schema.

CREATE ANY JOB

Create, alter, or drop jobs, schedules, or programs in any schema.

Note: This extremely powerful privilege allows the grantee to execute code as any other user. It should be granted with caution.

CREATE EXTERNAL JOB

Create in the grantee's schema an executable scheduler job that runs on the operating system.

EXECUTE ANY PROGRAM

Use any program in a job in the grantee's schema.

EXECUTE ANY CLASS

Specify any job class in a job in the grantee's schema.

MANAGE SCHEDULER

Create, alter, or drop any job class, window, or window group.

LIBRARIES:

--

CREATE LIBRARY

Create external procedure or function libraries in the grantee's schema.

CREATE ANY LIBRARY

Create external procedure or function libraries in any schema.

DROP ANY LIBRARY

Drop external procedure or function libraries in any schema.

MATERIALIZED VIEWS:

--

CREATE MATERIALIZED VIEW

Create a materialized view in the grantee's schema.

CREATE ANY MATERIALIZED VIEW

Create materialized views in any schema.

ALTER ANY MATERIALIZED VIEW

Alter materialized views in any schema.

DROP ANY MATERIALIZED VIEW

Drop materialized views in any schema.

QUERY REWRITE

This privilege has been deprecated. No privileges are needed for a user to enable rewrite for a materialized view that references tables or views in the user's own schema.

GLOBAL QUERY REWRITE

Enable rewrite using a materialized view when that materialized view references tables or views in any schema.

ON COMMIT REFRESH

Create a refresh-on-commit materialized view on any table in the database.

Alter a refresh-on-demand materialized on any table in the database to refresh-on-commit.

FLASHBACK ANY TABLE

Issue a SQL Flashback Query on any table, view, or materialized view in any schema. This privilege is not needed to execute the DBMS_FLASHBACK procedures.

OPERATORS:

--

CREATE OPERATOR

Create an operator and its bindings in the grantee's schema.

CREATE ANY OPERATOR

Create an operator and its bindings in any schema and create a comment on an operator in any schema.

ALTER ANY OPERATOR

Modify an operator in any schema.

DROP ANY OPERATOR

Drop an operator in any schema.

EXECUTE ANY OPERATOR

Reference an operator in any schema.

OUTLINES:

--

CREATE ANY OUTLINE

Create public outlines that can be used in any schema that uses outlines.

ALTER ANY OUTLINE

Modify outlines.

DROP ANY OUTLINE

Drop outlines.

PROCEDURES:

--

CREATE PROCEDURE

Create stored procedures, functions, and packages in the grantee's schema.

CREATE ANY PROCEDURE

Create stored procedures, functions, and packages in any schema.

ALTER ANY PROCEDURE

Alter stored procedures, functions, or packages in any schema.

DROP ANY PROCEDURE

Drop stored procedures, functions, or packages in any schema.

EXECUTE ANY PROCEDURE

Execute procedures or functions, either standalone or packaged.

Reference public package variables in any schema.

PROFILES:

--

CREATE PROFILE

Create profiles.

ALTER PROFILE

Alter profiles.

DROP PROFILE

Drop profiles.

ROLES:

--

CREATE ROLE

Create roles.

ALTER ANY ROLE

Alter any role in the database.

DROP ANY ROLE

Drop roles.

GRANT ANY ROLE

Grant any role in the database.

ROLLBACK SEGMENTS:

--

CREATE ROLLBACK SEGMENT

Create rollback segments.

ALTER ROLLBACK SEGMENT

Alter rollback segments.

DROP ROLLBACK SEGMENT

Drop rollback segments.

SEQUENCES:

--

CREATE SEQUENCE

Create sequences in the grantee's schema.

CREATE ANY SEQUENCE

Create sequences in any schema.

ALTER ANY SEQUENCE

Alter any sequence in the database.

DROP ANY SEQUENCE

Drop sequences in any schema.

SELECT ANY SEQUENCE

Reference sequences in any schema.

SESSIONS:

--

CREATE SESSION

Connect to the database.

ALTER RESOURCE COST

Set costs for session resources.

ALTER SESSION

Issue ALTER SESSION statements.

RESTRICTED SESSION

Logon after the instance is started using the SQL*Plus STARTUP RESTRICT statement.

SNAPSHOTS:

See MATERIALIZED VIEWS

SYNONYMS:

--

CREATE SYNONYM

Create synonyms in the grantee's schema.

CREATE ANY SYNONYM

Create private synonyms in any schema.

CREATE PUBLIC SYNONYM

Create public synonyms.

DROP ANY SYNONYM

Drop private synonyms in any schema.

DROP PUBLIC SYNONYM

Drop public synonyms.

TABLES:

Note: For external tables, the only valid privileges are CREATE ANY TABLE, ALTER ANY TABLE, DROP ANY TABLE, and SELECT ANY TABLE.

CREATE TABLE

Create tables in the grantee's schema.

CREATE ANY TABLE

Create tables in any schema. The owner of the schema containing the table must have space quota on the tablespace to contain the table.

ALTER ANY TABLE

Alter any table or view in any schema.

BACKUP ANY TABLE

Use the Export utility to incrementally export objects from the schema of other users.

DELETE ANY TABLE

Delete rows from tables, table partitions, or views in any schema.

DROP ANY TABLE

Drop or truncate tables or table partitions in any schema.

INSERT ANY TABLE

Insert rows into tables and views in any schema.

LOCK ANY TABLE

Lock tables and views in any schema.

SELECT ANY TABLE

Query tables, views, or materialized views in any schema.

FLASHBACK ANY TABLE

Issue a SQL Flashback Query on any table, view, or materialized view in any schema. This privilege is not needed to execute the DBMS_FLASHBACK procedures.

UPDATE ANY TABLE

Update rows in tables and views in any schema.

TABLESPACES:

--

CREATE TABLESPACE

Create tablespaces.

ALTER TABLESPACE

Alter tablespaces.

DROP TABLESPACE

Drop tablespaces.

MANAGE TABLESPACE

Take tablespaces offline and online and begin and end tablespace backups.

UNLIMITED TABLESPACE

Use an unlimited amount of any tablespace. This privilege overrides any specific quotas assigned. If you revoke this privilege from a user, then the user's schema objects remain but further tablespace allocation is denied unless authorized by specific tablespace quotas. You cannot grant this system privilege to roles.

TRIGGERS:

--

CREATE TRIGGER

Create a database trigger in the grantee's schema.

CREATE ANY TRIGGER

Create database triggers in any schema.

ALTER ANY TRIGGER

Enable, disable, or compile database triggers in any schema.

DROP ANY TRIGGER

Drop database triggers in any schema.

ADMINISTER DATABASE TRIGGER

Create a trigger on DATABASE. You must also have the CREATE TRIGGER or CREATE ANY TRIGGER system privilege.

TYPES:

--

CREATE TYPE

Create object types and object type bodies in the grantee's schema.

CREATE ANY TYPE

Create object types and object type bodies in any schema.

ALTER ANY TYPE

Alter object types in any schema.

DROP ANY TYPE

Drop object types and object type bodies in any schema.

EXECUTE ANY TYPE

Use and reference object types and collection types in any schema, and invoke methods of an object type in any schema if you make the grant to a specific user. If you grant EXECUTE ANY TYPE to a role, then users holding the enabled role will not be able to invoke methods of an object type in any schema.

UNDER ANY TYPE

Create subtypes under any nonfinal object types.

USERS:

--

CREATE USER

Create users. This privilege also allows the creator to:

  • Assign quotas on any tablespace.

  • Set default and temporary tablespaces.

  • Assign a profile as part of a CREATE USER statement.

ALTER USER

Alter any user. This privilege authorizes the grantee to:

  • Change another user's password or authentication method.

  • Assign quotas on any tablespace.

  • Set default and temporary tablespaces.

  • Assign a profile and default roles.

DROP USER

Drop users

VIEWS:

--

CREATE VIEW

Create views in the grantee's schema.

CREATE ANY VIEW

Create views in any schema.

DROP ANY VIEW

Drop views in any schema.

UNDER ANY VIEW

Create subviews under any object views.

FLASHBACK ANY TABLE

Issue a SQL Flashback Query on any table, view, or materialized view in any schema. This privilege is not needed to execute the DBMS_FLASHBACK procedures.

MERGE ANY VIEW

If a user has been granted the MERGE ANY VIEW privilege, then for any query issued by that user, the optimizer can use view merging to improve query performance without performing the checks that would otherwise be performed to ensure that view merging does not violate any security intentions of the view creator. See also Oracle Database Reference for information on the OPTIMIZER_SECURE_VIEW_MERGING parameter and Oracle Database Performance Tuning Guide for information on view merging.

MISCELLANEOUS:

--

ANALYZE ANY

Analyze any table, cluster, or index in any schema.

AUDIT ANY

Audit any object in any schema using AUDIT schema_objects statements.

CHANGE NOTIFICATION

Create a registration on queries and receive database change notifications in response to DML or DDL changes to the objects associated with the registered queries. Please refer to Oracle Database Application Developer's Guide - Fundamentals for more information on database change notification.

COMMENT ANY TABLE

Comment on any table, view, or column in any schema.

EXEMPT ACCESS POLICY

Bypass fine-grained access control.

Caution: This is a very powerful system privilege, as it lets the grantee bypass application-driven security policies. Database administrators should use caution when granting this privilege.

FORCE ANY TRANSACTION

Force the commit or rollback of any in-doubt distributed transaction in the local database.

Induce the failure of a distributed transaction.

FORCE TRANSACTION

Force the commit or rollback of the grantee's in-doubt distributed transactions in the local database.

GRANT ANY OBJECT PRIVILEGE

Grant any object privilege that the object owner is permitted to to grant.

Revoke any object privilege that was granted by the object owner or by some other user with the GRANT ANY OBJECT PRIVILEGE privilege.

GRANT ANY PRIVILEGE

Grant any system privilege.

RESUMABLE

Enable resumable space allocation.

SELECT ANY DICTIONARY

Query any data dictionary object in the SYS schema. This privilege lets you selectively override the default FALSE setting of the O7_DICTIONARY_ACCESSIBILITY initialization parameter.

SELECT ANY TRANSACTION

Query the contents of the FLASHBACK_TRANSACTION_QUERY view.

Caution: This is a very powerful system privilege, as it lets the grantee view all data in the database, including past data. This privilege should be granted only to users who need to use the Oracle Flashback Transaction Query feature.

SYSDBA

Perform STARTUP and SHUTDOWN operations.

ALTER DATABASE: open, mount, back up, or change character set.

CREATE DATABASE.

ARCHIVELOG and RECOVERY.

CREATE SPFILE.

Includes the RESTRICTED SESSION privilege.

SYSOPER

Perform STARTUP and SHUTDOWN operations.

ALTER DATABASE: open, mount, or back up.

ARCHIVELOG and RECOVERY.

CREATE SPFILE.

Includes the RESTRICTED SESSION privilege.

CONNECT, RESOURCE, and DBA

These roles are provided for compatibility with previous versions of Oracle Database. You can determine the privileges encompassed by these roles by querying the DBA_SYS_PRIVS data dictionary view.

Note: Oracle recommends that you design your own roles for database security rather than relying on these roles. These roles may not be created automatically by future versions of Oracle Database.

See Also: Oracle Database Reference for a description of the DBA_SYS_PRIVS view

DELETE_CATALOG_ROLE EXECUTE_CATALOG_ROLE SELECT_CATALOG_ROLE

These roles are provided for accessing data dictionary views and packages.

See Also: Oracle Database Administrator's Guide for more information on these roles

EXP_FULL_DATABASE

IMP_FULL_DATABASE

These roles are provided for convenience in using the import and export utilities.

See Also: Oracle Database Utilities for more information on these roles

AQ_USER_ROLE

AQ_ADMINISTRATOR_ROLE

You need these roles to use Oracle Advanced Queuing.

See Also: Oracle Streams Advanced Queuing User's Guide and Reference for more information on these roles

SNMPAGENT

This role is used by the Enterprise Manager Intelligent Agent.

See Also: Oracle Enterprise Manager Administrator's Guide

RECOVERY_CATALOG_OWNER

You need this role to create a user who owns a recovery catalog.

See Also: Oracle Database Backup and Recovery Advanced User's Guide for more information on recovery catalogs


Table 18-2 Oracle Database Predefined Roles

Predefined Role Purpose

HS_ADMIN_ROLE

A DBA using Oracle Database heterogeneous services needs this role to access appropriate tables in the data dictionary.

See Also: Oracle Database Heterogeneous Connectivity Administrator's Guide for more information

SCHEDULER_ADMIN

This role allows the grantee to execute the procedures of the DBMS_SCHEDULER package. It includes all of the job scheduler system privileges and is included in the DBA role.

See Also: Oracle Database Administrator's Guide for more information on the DBMS_SCHEDULER package


Table 18-3 Object Privileges Available for Particular Objects

Object Privilege Table View Sequence Procedure, Function, Package (Note 1) Material-ized View Directory Library User- defined Type Operator Indextype

ALTER (Note 2)

X

--

X

--

--

--

--

--

--

--

DELETE

X

X

--

--

X

(Note 3)

--

--

--

--

--

EXECUTE

--

--

--

X

(Note 2)

--

--

X

(Note 2)

X

(Note 2)

X

(Note 2)

X

(Note 2)

DEBUG

X

X

--

X

--

--

--

X

--

--

FLASHBACK

X

X

--

--

X

--

--

--

--

--

INDEX

X

--

--

--

--

--

--

--

--

--

INSERT

X

X

--

--

X

(Note 3)

--

--

--

--

--

ON COMMIT REFRESH

X

--

--

--

--

--

--

--

--

--

QUERY REWRITE

X

--

--

--

--

--

--

--

--

--

READ

--

--

--

--

--

X

--

--

--

--

REFERENCES

X

X

--

--

--

--

--

--

--

--

SELECT

X

X

X

--

X

--

--

--

--

--

UNDER

--

X

--

--

--

--

--

X

--

--

UPDATE

X

X

--

--

X (Note 3)

--

--

--

--

--

WRITE

--

--

--

--

--

X

--

--

--

--


Note 1: Oracle Database treats a Java class, source, or resource as if it were a procedure for purposes of granting object privileges.

Note 2: Job scheduler objects are created using the DBMS_SCHEDULER package. After these objects are created, you can grant the EXECUTE object privilege on job scheduler classes and programs. You can grant ALTER privilege on job scheduler jobs, programs, and schedules.

Note 3: The DELETE, INSERT, and UPDATE privileges can be granted only to updatable materialized views.

Table 18-4 Object Privileges and the Operations They Authorize

Object Privilege Operations Authorized

TABLE PRIVILEGES

The following table privileges authorize operations on a table. Any one of following object privileges allows the grantee to lock the table in any lock mode with the LOCK TABLE statement.

Note: For external tables, the only valid object privileges are ALTER and SELECT.

ALTER

Change the table definition with the ALTER TABLE statement.

DELETE

Remove rows from the table with the DELETE statement.

Note: You must grant the SELECT privilege on the table along with the DELETE privilege if the table is on a remote database.

DEBUG

Access, through a debugger:

  • PL/SQL code in the body of any triggers defined on the table

  • Information on SQL statements that reference the table directly

INDEX

Create an index on the table with the CREATE INDEX statement.

INSERT

Add new rows to the table with the INSERT statement.

REFERENCES

Create a constraint that refers to the table. You cannot grant this privilege to a role.

SELECT

Query the table with the SELECT statement.

UPDATE

Change data in the table with the UPDATE statement.

Note: You must grant the SELECT privilege on the table along with the UPDATE privilege if the table is on a remote database.

VIEW PRIVILEGES

The following view privileges authorize operations on a view. Any one of the following object privileges allows the grantee to lock the view in any lock mode with the LOCK TABLE statement.

To grant a privilege on a view, you must have that privilege with the GRANT OPTION on all of the base tables of the view.

DEBUG

Access, through a debugger:

  • PL/SQL code in the body of any triggers defined on the view

  • Information on SQL statements that reference the view directly

DELETE

Remove rows from the view with the DELETE statement.

INSERT

Add new rows to the view with the INSERT statement.

REFERENCES

Define foreign key constraints on the view.

SELECT

Query the view with the SELECT statement.

UNDER

Create a subview under this view. You can grant this object privilege only if you have the UNDER ANY VIEW privilege WITH GRANT OPTION on the immediate superview of this view.

UPDATE

Change data in the view with the UPDATE statement.

SEQUENCE PRIVILEGES

The following sequence privileges authorize operations on a sequence.

ALTER

Change the sequence definition with the ALTER SEQUENCE statement.

SELECT

Examine and increment values of the sequence with the CURRVAL and NEXTVAL pseudocolumns.

PROCEDURE, FUNCTION, PACKAGE PRIVILEGES

The following procedure, function, and package privileges authorize operations on procedures, functions, and packages. These privileges also apply to Java sources, classes, and resources, which Oracle Database treats as though they were procedures for purposes of granting object privileges.

DEBUG

Access, through a debugger, all public and nonpublic variables, methods, and types defined on the object.

Place a breakpoint or stop at a line or instruction boundary within the procedure, function, or package. This privilege grants access to the declarations in the method or package specification and body.

EXECUTE

Execute the procedure or function directly, or access any program object declared in the specification of a package, or compile the object implicitly during a call to a currently invalid or uncompiled function or procedure. This privilege does not allow the grantee to explicitly compile using ALTER PROCEDURE or ALTER FUNCTION. For explicit compilation you need the appropriate ALTER system privilege.

Access, through a debugger, public variables, types, and methods defined on the procedure, function, or package. This privilege grants access to the declarations in the method or package specification only.

Note: Users do not need this privilege to execute a procedure, function, or package indirectly.

See Also: Oracle Database Concepts and Oracle Database Application Developer's Guide - Fundamentals

MATERIALIZED VIEW PRIVILEGES

The following materialized view privileges authorize operations on a materialized view.

ON COMMIT REFRESH

Create a refresh-on-commit materialized view on the specified table.

QUERY REWRITE

Create a materialized view for query rewrite using the specified table.

SELECT

Query the materialized view with the SELECT statement.

SYNONYM PRIVILEGES

Synonym privileges are the same as the privileges for the base object. Granting a privilege on a synonym is equivalent to granting the privilege on the base object. Similarly, granting a privilege on a base object is equivalent to granting the privilege on all synonyms for the object. If you grant to a user a privilege on a synonym, then the user can use either the synonym name or the base object name in the SQL statement that exercises the privilege.

DIRECTORY PRIVILEGES

The following directory privileges provide secured access to the files stored in the operating system directory to which the directory object serves as a pointer. The directory object contains the full path name of the operating system directory where the files reside. Because the files are actually stored outside the database, Oracle Database server processes also need to have appropriate file permissions on the file system server. Granting object privileges on the directory database object to individual database users, rather than on the operating system, allows the database to enforce security during file operations.

READ

Read files in the directory.

WRITE

Write files in the directory. This privilege is useful only in connection with external tables. It allows the grantee to determine whether the external table agent can write a log file or a bad file to the directory.

Restriction: This privilege does not allow the grantee to write to a BFILE.

LIBRARY PRIVILEGE

The following library privilege authorizes operations on a library.

EXECUTE

Use and reference the specified object and invoke its methods.

OBJECT TYPE PRIVILEGES

The following object type privileges authorize operations on a database object type.

DEBUG

Access, through a debugger, all public and nonpublic variables, methods, and types defined on the object type.

Place a breakpoint or stop at a line or instruction boundary within the type body.

EXECUTE

Use and reference the specified object and invoke its methods.

Access, through a debugger, public variables, types, and methods defined on the object type.

UNDER

Create a subtype under this type. You can grant this object privilege only if you have the UNDER ANY TYPE privilege WITH GRANT OPTION on the immediate supertype of this type.

INDEXTYPE PRIVILEGE

The following indextype privilege authorizes operations on indextypes.

EXECUTE

Reference an indextype.

OPERATOR PRIVILEGE

The following operator privilege authorizes operations on user-defined operators.

EXECUTE

Reference an operator.


Examples

Granting a System Privilege to a User: Example To grant the CREATE SESSION system privilege to the sample user hr, allowing hr to log on to Oracle Database, issue the following statement:

GRANT CREATE SESSION 
   TO hr; 

Granting System Privileges to a Role: Example The following statement grants appropriate system privileges to a data warehouse manager role, which was created in the "Creating a Role: Example":

GRANT
     CREATE ANY MATERIALIZED VIEW
   , ALTER ANY MATERIALIZED VIEW
   , DROP ANY MATERIALIZED VIEW
   , QUERY REWRITE
   , GLOBAL QUERY REWRITE
   TO dw_manager
   WITH ADMIN OPTION;

The dw_manager privilege domain now contains the system privileges related to materialized views.

Granting a Role with the Admin Option: Example To grant the dw_manager role with the ADMIN OPTION to the sample user sh, issue the following statement:

GRANT dw_manager 
   TO sh 
   WITH ADMIN OPTION; 

User sh can now perform the following operations with the dw_manager role:

  • Enable the role and exercise any privileges in the privilege domain of the role, including the CREATE MATERIALIZED VIEW system privilege

  • Grant and revoke the role to and from other users

  • Drop the role

Granting Object Privileges to a Role: Example The following example grants the SELECT object privileges to a data warehouse user role, which was created in the "Creating a Role: Example":

GRANT SELECT ON sh.sales TO warehouse_user;

Granting a Role to a Role: Example The following statement grants the warehouse_user role to the dw_manager role. Both roles were created in the "Creating a Role: Example":

GRANT warehouse_user TO dw_manager; 

The dw_manager role now contains all of the privileges in the domain of the warehouse_user role.

Granting an Object Privilege on a Directory: Example To grant READ on directory bfile_dir to user hr, with the GRANT OPTION, issue the following statement:

GRANT READ ON DIRECTORY bfile_dir TO hr
   WITH GRANT OPTION;

Granting Object Privileges on a Table to a User: Example To grant all privileges on the table oe.bonuses, which was created in "Merging into a Table: Example", to the user hr with the GRANT OPTION, issue the following statement:

GRANT ALL ON bonuses TO hr 
   WITH GRANT OPTION; 

The user hr can subsequently perform the following operations:

  • Exercise any privilege on the bonuses table

  • Grant any privilege on the bonuses table to another user or role

Granting Object Privileges on a View: Example To grant SELECT and UPDATE privileges on the view emp_view, which was created in "Creating a View: Example", to all users, issue the following statement:

GRANT SELECT, UPDATE 
   ON emp_view TO PUBLIC; 

All users can subsequently query and update the view of employee details.

Granting Object Privileges to a Sequence in Another Schema: Example To grant SELECT privilege on the customers_seq sequence in the schema oe to the user hr, issue the following statement:

GRANT SELECT 
   ON oe.customers_seq TO hr; 

The user hr can subsequently generate the next value of the sequence with the following statement:

SELECT oe.customers_seq.NEXTVAL 
   FROM DUAL; 

Granting Multiple Object Privileges on Individual Columns: Example To grant to user oe the REFERENCES privilege on the employee_id column and the UPDATE privilege on the employee_id, salary, and commission_pct columns of the employees table in the schema hr, issue the following statement:

GRANT REFERENCES (employee_id), 
      UPDATE (employee_id, salary, commission_pct) 
   ON hr.employees
   TO oe; 

The user oe can subsequently update values of the employee_id, salary, and commission_pct columns. User oe can also define referential integrity constraints that refer to the employee_id column. However, because the GRANT statement lists only these columns, oe cannot perform operations on any of the other columns of the employees table.

For example, oe can create a table with a constraint:

CREATE TABLE dependent 
   (dependno   NUMBER, 
    dependname VARCHAR2(10), 
    employee   NUMBER 
   CONSTRAINT in_emp REFERENCES hr.employees(employee_id) );

The constraint in_emp ensures that all dependents in the dependent table correspond to an employee in the employees table in the schema hr.

반응형

'Database > ORACLE' 카테고리의 다른 글

rman Tool  (0) 2010.02.01
WS1-2-ch18. Data Pump (expdp/impdp) overview  (0) 2010.02.01
`BIN$+......==$0` 알수 없는 테이블..  (0) 2010.01.14
sqlplus 환경 설정  (0) 2010.01.08
Partition Table  (0) 2009.12.29
반응형

<PARTITION TABLE>
 

 

1. partition table 생성하기

 

create table part_tbl
( in_date number primary key ,
empno   number,
ename   varchar2(20),
job   varchar2(20) )
partition by range (in_date)
(
partition part_tbl_200803  values less than (20080332) tablespace pts_03,
partition part_tbl_200804  values less than (20080432) tablespace pts_04,
partition part_tbl_200805  values less than (20080532) tablespace pts_05,
partition part_tbl_max  values less than (maxvalue) tablespace pts_max
);

 


2. add partition 하기

 

6월 partition을 add하고 싶은 경우 다음과 같이 할 수 있다.

 

alter table part_tbl add partition part_tbl_200806 values less than (20080632) tablespace pts_06;

 

# 단 MAX 파티션 테이블이 있는경우는 add  partition 할 수 없다!
따라서 위 예제에서 생성된 파티션 테이블에서는 add partition 불가!!

 

 

3. 특정 partition 을 삭제하기

 

3월에 해당하는 partition을 없애고 싶은 경우는 다음과 같이 실행한다.

 

alter table part_tbl drop partition part_tbl_200803;

 
만약..
drop된 후에 새로 3월에 해당하는 데이타가 입력되면
4월의 partition이 less then (20080432) 으로 되어 있으므로
4월에 해당하는 partition에 저장된다.

 


3. partition 나누기
 
6월에 해당하는 partition을 생성하려면 MAX partition에 add하는 것으로는 불가능하고 MAX partition을 split 해야 한다.

 

alter table part_tbl split partition part_tbl_max at (20080632)
into (partition part_tbl_200806 tablespace pts_06, partition part_tbl_max tablespace pts_max);

 

+)

into(partition AAA, partition BBB) -> BBB파티션을 AAA 파티션으로 split한다.


위와 같이 하면 기존의 MAX 파티션 테이블에서 6월31일을 이전 데이터는 part_tbl_200806에 옮겨지고
MAX 파티션 테이블에는 6월31일 이후의 데이터가 들어있게 된다.

 


4. partition name을 변경하기

 
partition name 을 바꾸고 싶다면 다음과 같이 실행한다.

 

alter table part_tbl rename partition part_tbl_200805 to part_tbl_200805_new;

 
5. partition의 tablespace를 옮기기

 

partition part_tbl_05을 저장하는 tablespace를 pts_05 에서 pts_new로 바꾸고 싶은 경우는 다음과 같이 실행한다.


alter table part_tbl move partition part_tbl_05 tablespace pts_new nologging;

 

 

6. 특정 partition의 data를 truncate하기

 
 partition의 data를 모두 삭제하려면 truncate하는 방법을 사용할 수가 있는 데,
 truncate는 rollback 이 불가능하며 특정 partition 전체를 삭제하므로 주의하여 사용하여야 한다.

 

alter table part_tbl truncate partition part_tbl_03;

 

 

7. Partition table의 물리적인 속성 변경하기

 
partition table은 특정 partition의 속성만 변경할 수 있고,
table의 속성을 변경하여 전체 partition에 대해 동일한 변경을 할 수 있다.

 
alter table part_tbl storage( next 10M);
 -> part_tbl 의 모든 partition의 next 값이 변경된다.

 
alter table part_tbl modify partition part_tbl_05 storage ( maxextents 1000 );
 -> part_tbl_05 partition의 maxextents 값만 변경한다.

 

 

8. Index의 관리


변경작업을 통해 테이블 파티션이 변경된 경우 해당 테이블에 관련된 인덱스를 rebuild 해야합니다.

 
 1) local 인덱스인 경우

 
DDL작업을 통해 변경된 파티션 테이블에 걸려있는 해당 local 인덱스만  "UNUSABLE" 상태가 된다.
 -> MAX를 Split 한경우는 MAX 파티션과 Split로 새롭게 생성된 파티션의 인덱스 상태만 "UNUSABLE" 된다.

따라서 해당 파티션 인덱스를 반드시 rebuild 해 주어야 합니다.


-- 파티션 상태 확인

select INDEX_NAME, PARTITION_NAME, HIGH_VALUE, STATUS, TABLESPACE_NAME

from user_ind_partitions;

 
-- local Index rebuild 하기

alter index 인덱스이름 rebuild partition 파티션이름;

 
예제)

part_tbl_max 를 part_tbl_200806로 split 했을경우
각각의 파티션에 걸린 인덱스 part_tbl_indx_pk1 는  UNUSABLE 상태가 된다.

 

NDEX_NAME             PARTITION_NAME           HIGH_VALUE    STATUS           TABLESPACE_NAME

------------------------ ---------------------------- ---------------- ----------------- ------------------------------

part_tbl_indx_pk1      part_tbl_200804      '20080432'      USABLE            pts_04

part_tbl_indx_pk1      part_tbl_200805      '20080432'      USABLE            pts_05

part_tbl_indx_pk1      part_tbl_200806      '20080632'      UNUSABLE        pts_06

part_tbl_indx_pk1      part_tbl_max            MAXVALUE       UNUSABLE        pts_max

 

해당 파티션 인텍스를 rebuild 해준다.

alter index WEMS_BPEMAAN_PK1 rebuild partition WEMS_BPEMAAN_200806_P6;

alter index WEMS_BPEMAAN_PK1 rebuild partition WEMS_BPEMAAN_MAX;

 

 2)global Index인 경우

 

 - 변경된 해당 파티션 뿐만 아니라 해당 테이블 파티션에 관련된 모든 global 인덱스 상태를 "UNUSABLE"로 만든다.

따라서 인덱스 전체를 반드시 rebuild 해 주어야 합니다.

 

-- global Index rebuild 하기

alter index 인덱스이름 rebuild;

[출처] [oracle] PARTITION TABLE|작성자


반응형
반응형

LOB 정보가 기간이 지나 삭제가 필요할때...

LOB 정보가 있는 테이블 : LOB_TABLE
LOB 정보가 있는 필드 : LOB_DATA

-- LOB_TABLE 있는 LOG_DATA 필드의 값을 모두 없는 것으로 처리
UPDATE LOB_TABLE
     SET LOG_DATA = EMPTY_CLOB()
 WHERE 조건

-- LOB 공간 SHRINK 할수 있도록 데이터 압축해 놓기
ALTER TABLE LOB_TABLE
MODIFY LOB(LOB_DATA) (SHRINK SPACE COMPACT);

* 만약 에러가 나면 ROW MOVEMENT ENABLE 설정을 참고 !

-- LOB 공간 실제 SHRINK 하기
ALTER TABLE LOB_TABLE
MODIFY LOB(LOB_DATA) (SHRINK SPACE);
반응형
반응형

 

박중수 | 엔커블루 기술본부 대표 컨설턴트

기업에서의 데이터 증가는 기하급수적으로 늘어나고 있으며 그에 따른 데이터베이스 성능도 대용량을 처리할 수 있도록 발전하고 있다. 따라서 데이터베이스 관리자는 예전과 달리 데이터베이스의 운영을 매뉴얼하게 할 수 있는 상태에 직면해 있으며, 자동화된 모니터링 및 Alerts로 안정적인 서비스에 대응할 수 있는 툴을 원하고 있다. 이러한 요구사항을 위한 토드의 GUI 환경에서의 데이터베이스 모니터링 기능을 살펴보자.

데이터베이스 개발에 있어 토드(Toad)를 사용하는 사람들은 일반적으로 “토드는 개발자들을 위한 개발 툴”이란 생각을 많이 한다. 즉 단순히 SQL 문장이나 PL/SQL 문장을 빠르고 쉽게 개발할 수 있고, 데이터베이스 객체의 생성 및 변경 작업을 GUI 환경에서 간단하게 수행하며 소스코드 상의 문제점들을 자동으로 찾아주고, 디버깅 기능을 통해 개발자들의 수고를 덜어 줄 수 있는 툴 정도로만 인식하고 있는 것이다. 하지만 토드를 좀 더 세밀하게 들여다보면 개발자만을 위한 툴이 아닌 데이터베이스를 관리(management)하는 DBA(Database Administrator)가 사용할 수 있는 다양한 기능들이 숨겨져 있다. 이 글에서는 토드에 숨겨진 유용한 기능에 대해 소개하고자 한다.

DBA의 역할은 무엇일까?

DBA는 현재 운영되고 있는 시스템, 데이터베이스, 애플리케이션, 네트워크, 서비스 등의 다양한 환경을 구성하고 설치, 보안, 운영 및 설계나 개발 단계에 직, 간접적으로 참여해 전체 구성이 원활하게 유지되도록 하는 업무를 담당하고 있다.
이러한 업무를 수행하다 보면 원하는 서비스가 제대로 동작하지 못하고 특정 부분에 대한 장애가 발생하거나 알 수 없는 그 무엇인가에 의해 성능이 원하는 만큼 나오지 않을 경우도 있다. 특히 DBA에게 내·외적 요소에 의한 뜻하지 않는 돌발상황으로 인해 소비되는 시간이나 노력은 가장 큰 부담이다. 이럴 경우 DBA는 누군가가 현재의 시스템이나 데이터베이스의 부하 없이 효율적으로 문제점을 찾아내어 원인 파악을 해주고 문제점을 해결할 방법을 제시해 준다면 하늘로 날아갈 것 같은 기분을 느낄 것이다.
실제 DBA들은 이로 인해 발생하는 비용을 최소화하기 위해 툴을 사용한다. 하지만 문제점을 감지하는 툴, 문제점을 분석하는 툴, 문제점을 해결하는 툴에 이르기까지 다양한 툴 도입에 따라 발생하는 비용 부담과 함께 툴을 효과적으로 사용하고 있는가를 생각해보면 힘이 빠질 수밖에 없다.
이 글에서는 툴을 효과적으로 사용할 수 있는 정보를 제공하기 위해 가장 널리 사용되는 토드라는 데이터베이스 개발 툴을 선택했다. 특히 토드는 개발 툴 위주로 개발이 됐지만 ‘DBA 모듈’이라는 옵션 기능이 있어 토드 하나만 갖고도 데이터베이스를 최적의 상태로 유지할 수 있는 기능이 있다. 물론 전문적으로 감지·분석·해결에 초점을 맞춘 방대한 툴과의 비교는 어렵겠지만 그래도 적은 비용으로 문제를 해결할 수 있는 솔루션이 있다면 좋지 않겠는가.

DB의 문제점을 발견하라!

토드를 구입했다고 해서 DBA 기능을 전부 사용할 수 있는 것은 아니다(‘토드 DBA 모듈’은 옵션 제품이다). 제품을 구입할 당시에 DBA 모듈이라는 제품을 추가적으로 구입해야 사용이 가능하다. 하지만 개발 위주의 작업이 아닌 전사적인 방법으로 토드를 사용할 것이라면 추천할 만한 사항이라고 생각한다. 그러면 자신이 사용하고 있는 토드를 갖고 이 DBA 기능을 어떻게 사용할 수 있을까?
확인할 수 있는 가장 간단한 방법은 토드의 메인 메뉴 중에서 DBA 메뉴를 클릭해 보면 그 아래 리스트가 길게 나와 있느냐 짧게 나와 있느냐에 따라 확인할 수 있다. <화면 1>처럼 길게 리스트가 나온다면 DBA의 기능을 최적의 상태에서 사용할 수 있다는 뜻이다. 그럼 토드의 DBA 기능을 Detect, Diagnostic, Resolve라는 3개의 단계에 초점을 맞추어 살펴보자.

<화면 1> DBA 메뉴


데이터베이스에 문제가 발생하면 DBA는 일단 원인부터 파악한다. 하지만 어느 부분이 문제가 있는지를 감지하기란 사막에서 모래알을 찾는 것만큼 어려운 일이다. 토드에서 지원하고 있는 DBA 기능 중에서 데이터베이스 모니터(Database Monitor), 헬쓰 체크(Health Check), 인스턴스 매니저(Instance Manager)를 통해 현재의 데이터베이스 상태를 감지할 수 있다.

데이터베이스 모니터

우선 데이터베이스 운영자는 데이터베이스의 성능을 높이기 위해 물리적인 I/O의 병목현상을 제거함으로써 시스템의 메모리와 CPU 자원의 경합을 줄이며 안정적인 서비스를 제공할 수 있다. 그리고 데이터베이스 운영자는 각 세션들에서 발생되는 Wait Event(네트워크 통신이나 I/O 요청 또는 데이터베이스의 특정 자원을 여러 프로세스가 동시에 액세스할 때 발생하는 경합에 의한 대기)의 원인을 제거함으로써 원활한 응답속도를 유지해야 한다.
데이터베이스 모니터 기능은 데이터베이스의 Data Dictionary (V$SYSSTAT, V$SYSTEM_EVENT)를 이용해 메모리, I/O, Latch, 세션 그룹으로 나눠 관련 정보를 추출해 <화면 2>와 같이 9가지 그룹으로 사용자가 Refresh Rate(Interval)를 적용해 주어진 시간에 따라 변화되는 모습을 한 화면에서 볼 수 있다. 이에 성능과 관련된 문제점을 쉽게 파악할 수 있으며, 성능에 지장을 초래한 SQL의 진단 또는 초기 파라미터를 조정할 수 있다.

<화면 2> 데이터베이스 모니터


◆ 데이터베이스 모니터의 주요 기능
① Auto Refresh 설정 기능
② Refresh Rate 설정 기능
③ Alerts에 대한 Propagation 기능
④ 데이터베이스의 Data Dictionary(V$) 정보 그래픽 디스플레이 기능

이터베이스 모니터의 그래프 정보
① Logical I/O : 논리적인 I/O는 SGA(메모리)에 존재하는 데이터베이스 블럭의 Change, Current, Consistent Read들에 대한 통계 추이의 정보
② Physical I/O : 물리적인 I/O는 데이터파일(디스크)의 해당 블럭을 읽어 SGA(메모리)로 올리거나 또는 메모리에서 변경된 블럭을 데이터파일(디스크)로 작성, 그리고 LGWR에 의해서 온라인 리두(redo) 로그 파일로 작성되는 통계 추이의 정보
③ Event Wait : 데이터베이스는 시스템 또는 세션별로 발생하는 Wait 이벤트 통계 정보를 누적해 기록하는데 풀 스캔(Full Scan)시 I/O를 요청하고 대기하는 ‘Mulit-block Read’, 인덱스 스캔시 I/O를 요청하고 대기하는 ‘Single-block Read’, 테이블 스캔시 버퍼 캐시를 거치지 않는 ‘Direct Patch Read’ 등의 통계 추이의 정보
④ Sessions : Sessions는 데이터베이스에 접속한 모든 세션들을 활동 세션(active), 백그라운드 세션(system), 아이들(Idle) 세션으로 분류해 표현한 정보
⑤ all Rates : 사용자가 요청한 SQL에 대한 구문 분석(parse), 실행(execute), 변경 정보 영구저장(commit), 변경 정보 취소(rollback) 정보
⑥ Miss Rates : 데이터베이스의 대표적인 성능 지표인 버퍼 캐시(Buffer Cache) 미스율, 라이브러리/딕셔너리 미스율(SQL Area), 래치 미스율(Latch)의 정보
⑦ SGA Memory Usage : SGA에 할당된 메모리의 사용률에 대한 정보(Shared Pool, 버퍼 캐스, 로그 버퍼)
⑧ Shared Pool : SGA에 할당된 메모리 중 SQL에 대한 공유 메모리의 Detail 사용률에 대한 정보(라이브러리 캐시, 딕셔너리 캐시, Misc Area 등)
⑨ Index Query % : 데이터베이스에서 사용된 SQL 중 쿼리에 대해 인덱스 사용(Indexed %)과 미사용(Non-Indexed %)에 대한 정보

데이터베이스 모니터의 Alert
그렇다면 DBA는 현재 데이터베이스가 문제점이 있는지의 여부를 판단하기 위해 항상 데이터베이스 모니터링 툴을 보고만 있어야 하는가? 그렇다면 진정한 탐지 툴(Detection Tool)이라고 할 수가 없을 것이다. 이를 위해 Alert 기능을 제공한다. 토드 옵션의 데이터베이스 모니터를 찾아보면 모니터링하고자 하는 앞의 9가지 항목들에 대해 임계치(Thresholds)를 설정해 해당 임계치에 도달하면 Alert를 DBA에게 보여줄 수 있도록 지정할 수도 있다. 그러면 토드가 설치되어 있는 PC의 맨 아래에 Toad Database Monitor라는 아이콘이 나타나서 DBA에게 신호를 보내준다.

헬쓰 체크

데이터베이스 구축 후 시간이 지남에 따라 데이터의 크기는 현저하게 증가하게 되고 또한 다양한 문제점들이 나타나게 되는데, 인스턴스에서 발생하는 문제점들을 DBA가 찾아서 조치하기에는 시간과 비용이 만만치 않다. 이에 DBA는 C 검사를 원하는 항목(SGA, Analyze, Extent, JOB……)들에 대해 조건을 설정한다. 해당 조건을 만족하는 내용에 대해 자동으로 체크해 결과를 보여준다면 DBA의 역할은 그만큼 줄어들 것이며, 이를 통해 데이터베이스에 지장을 초래할 수 있는 원인들을 미연에 방지할 수 있다.

◆ 헬쓰 체크의 주요 기능
① 전체의 아이템을 수행하거나 특정한 아이템만 선택해 체크할 수 있다.
② 분석 결과에 대한 리포트
③ SGA 사용 내역
④ Unanalyzed Segments(테이블, 인덱스, 파티션 테이블/인덱스)
⑤ 100개가 넘는 Extent를 소유한 세그먼트
⑥ JOB의 Broken, Sysdate보다 이전의 JOB, Long running JOB 등

<화면 3>은 토드의 헬쓰 체크 기능을 수행한 화면이다. 여기에는 Checks and Options, Other Settings, Report Output 등 3가지 탭으로 구성되어 있는데, Check and Options 탭에서 이미 지정되어 있는 다양한 인스턴스 체크 사항 중에서 원하는 항목을 지정하고 그에 따른 값을 입력하고 실행하면 Report Output 탭에 Health Check를 수행한 결과를 보여준다.

<화면 3> 데이터베이스 헬쓰 체크


인스턴스 매니저

이 기능은 현재 동작 중인 데이터베이스의 인스턴스에 커넥션을 자동으로 수행해 Startup 상태인지 Shutdown 상태인지를 체크할 수 있으며, 토드에서 직접 Startup/Shutdown 명령을 수행하거나 Init 파라미터 파일을 빌딩(building)할 수도 있다.

<화면 4> 인스턴스 메니저


DB의 문제점을 분석하라!

데이터베이스의 문제점을 파악했으면 과연 이 문제점의 원인은 무엇이며, 현재 데이터베이스 성능에서 병목현상(Bottleneck)이 발생하는 영역은 어디인지에 대해 자세하게 분석해야 한다.
분석 작업은 시작해야 하는 포인트가 중요하다. 예를 들어, 오라클 데이터베이스에서 현재 심각하게 성능이 다운되는 현상이 발생하고 있다면 과연 이 문제가 메모리 쪽인지, I/O 쪽인지, I/O라면 데이터파일인지 리두 로그 파일인지를 파악해야 한다. 메모리라면 Shared Pool인지 데이터베이스 버퍼 캐시인지 리두 로그인지 판단해야 한다. DBA 입장에서 특정 문제점이 발생한 영역을 알 수 있다면 그 부분을 집중적으로 분석해 문제점을 해결해야 하는데, 토드는 이러한 분석을 쉽게 할 수 있는 다양한 기능들을 갖고 있다.

Database Probe

데이터베이스의 구성은 크게 메모리(SGA), 프로세스, 데이터파일(Online Redo Logfile, User Datafile)로 구성되며 서버 프로세스와 백그라운드 프로세스에 의해 자동적으로 운영된다. Database Probe는 <화면 5>와 같이 3개의 그룹으로 나뉘어 각 그룹별로 중요한 정보를 보여주게 된다.

<화면 5> Database Probe


먼저 프로세스 부분은 전용 서버 프로세스와 공유 서버 프로세스의 수 및 병렬 처리 내용과 데이터베이스 서버 프로세스가 사용하는 독점 메모리인 PGA 메모리의 사용 현황의 관계를 보여주고 있으며, 메모리(SGA) 부분은 서버 프로세스가 데이터를 처리하는 버퍼 캐시, SQL과 PL/SQL 문장을 저장하기 위한 Shared Pool, 공유 서버의 세션 정보를 저장하는 Large Pool, 데이터 블럭의 변경된 정보(Before/After)를 저장하는 리두 로그 버퍼, 자바 프로그램을 이용하는 영역의 Java Pool의 사용률을 보여주며, 마지막으로 데이터파일 부분은 파일의 크기와 현재까지의 사용률을 그래픽하게 처리하고 있어 데이터베이스의 전반적인 리소스를 얼마나 사용하고 있는지를 시각적으로 판단해 데이터베이스의 초기 파라미터 및 데이터파일의 크기 또는 리두 로그 파일의 크기 및 개수 등을 조정하는 데 필요한 정보를 제공한다.

◆ Database Probe의 주요 기능
① SGA 각 영역의 Hit Ratio 및 사용률 및 Wait/Retry 정보
② 전용 서버 프로세스 및 공유 서버 프로세스의 수 및 PGA 정보
③ 데이터파일의 전체 크기 및 사용률

Top Session Finder
현재 시스템에서 특정 리소스를 많이 사용하는 오라클 세션들을 발췌해 탑 리스트(Top List)로 보여준다. 앞의 Database Probe를 이용해 현재 데이터베이스 측면을 분석했으면, 그 내부에서 작업 중인 세션들에 대한 자세한 정보를 분석해야 할 것이다. 하지만 그 많은 세션들을 일일이 분석하기란 여간 힘든 일이 아니다. 그 중에서 시스템의 리소스를 많이 사용하는 세션이 문제점을 갖고 있기 때문에, 그에 따른 이벤트 정보를 토대로 탑 세션을 발췌한다. 예를 들어 CPU를 많이 사용하는 탑 세션, I/O를 많이 발생시키는 탑 세션처럼 DBA가 원하는 시스템 리소스 측면을 강조한 기능이라고 할 수 있다. <화면 6>에서는 세션들 중에서 ‘session logical reads’, 즉 논리적인 읽기가 큰 세션부터 내림차순으로 정렬된 정보를 Dataset 형태로 제공하고 있다.

<화면 6> Top Session Finder


◆ Top Session Finder의 주요 기능
① CPU, 메모리, 커서(CURSORS) 등과 같은 자원 그룹별로 문제 세션을 검색
② 데이터베이스 세션 정보의 결과를 Dataset 형태나 Pie Chart 형식으로 제공

세션 브라우저
세션 브라우저 기능은 데이터베이스에 접속 중인 모든 세션들에 대해 총괄적으로 세션 액티비티(Session Activity)를 분석하기 위해 제공된 기능이다. <화면 7>은 특정 세션의 Wait Event에 대한 상세 정보를 ‘Current Waits’와 ‘Total Waits’로 분리해 제공하고 있다. 특정 세션을 선택하면 다음과 같은 상세정보를 동적으로 추출할 수 있다.

<화면 7> 세션브라우저


- 세션 : 선택한 세션의 ID, 프로그램, 모듈, Machine, OS 유저, DB 유저 등의 정보를 제공
- 프로세스 : 선택한 세션의 프로세스 정보 제공
- I/O : 선택한 세션이 발생시킨 I/O 정보인 읽기/쓰기 정보 제공
- Waits : 선택한 세션에서 발생한 Wait Event 정보 제공
- Current Statement : 선택한 세션에서 수행 중인 SQL 문장 정보 제공
- Open Cursors : 선택한 세션이 오픈한 커서 정보 제공
- Access : 선택한 세션이 액세스한 객체 정보 제공
- Locks : 세션 잠금 정보 제공
- RBS Usage : 선택한 세션이 사용한 롤백 세그먼트(Rollback Segment) 정보 제공
- Long Ops : 선택한 세션이 배치(Batch)성 작업을 수행했을 경우 현재까지 진행된 상황에 대한 정보 제공
- Statistics : 선택한 세션에 대한 통계 정보 제공

OS 유틸리티
이 기능은 데이터베이스 측면이 아닌 데이터베이스가 동작 중인 시스템(OS) 부분의 정보를 분석하고자 할 경우 사용한다. 유닉스나 윈도우 계열의 OS를 사용할 경우 또는 해당 OS에 해당되는 정보를 분석하고자 할 경우 유용하게 사용할 수 있다. <화면 8>은 CPU의 사용률을 시스템, 사용자를 구분해 사용되고 있는 정보와 프로세스 정보 및 디스크 I/O에 대한 정보를 그래프로 제공하고 있어, 시스템의 전반적인 자원 사용율을 나타내고 있다.

<화면 8> OS 유틸리티 메뉴


<화면 9> 유닉스 모니터


DB상의 문제점을 어떻게 해결할 것인가?

데이터베이스의 문제점을 감지(detect)하고 분석(diagnostic)했으면, 그에 따른 행동을 취해야 한다. 일반적으로 제시하는 해결방안은 시스템 튜닝, 데이터베이스 튜닝, 애플리케이션 튜닝, SQL Statement 튜닝으로 구분할 수 있는 데, 토드에서는 문제점을 해결하기 위한 다양한 기능이 존재한다.

테이블 스페이스와 테이블 스페이스 맵

이는 데이터베이스의 논리적 구조를 이루는 가장 핵심적인 요소이다. 데이터베이스의 데이터가 존재하는 물리적인 데이터파일과 연결되어 있으며, 그 안에 세그먼트, 익스턴트(Extent), 블럭이라는 구조가 존재하고 있다. 만약 테이블 스페이스의 공간이 부족하거나, 데이터파일에 Fragmentation이 발생해 장애가 발생한 경우라면 해당 테이블 스페이스의 공간을 늘려주는 작업과 그 안에 존재하는 Fragmentation을 Coalesce하는 작업을 수행해 다시 재구성하는 문제를 생각해야 할 것이다. 또한 이로 인해 I/O Wait가 발생해 성능이 떨어지는 원인이 된다면 해당 데이터파일도 다시 재구성하거나 재구축하는 절차를 수행해야 한다. 이러한 과정을 손쉽게 수행할 수 있도록 하는 기능이 바로 테이블 스페이스 기능이다.
토드에서 테이블 스페이스와 데이터파일에 대한 정보를 변경할 수 있으며, 프리 스페이스(Free Space)와 해당 테이블 스페이스에 존재하는 객체 정보를 확인할 수 있다.
그리고 뒤에 있는 Space History와 I/O History 탭에서는 특정 테이블 스페이스나 데이터파일에 대한 Capacity Plan 정보를 확인할 수 있다. <화면 10>은 데이터베이스의 각 테이블 스페이스에 대해 할당된 크기와 가장 큰 연속된 공간 및 프리 스페이스를 보여주고 있다. 만약에 특정 세그먼트의 크기가 부족해 확장될 때 ‘MAX Mb’의 값보다 크다면 확장하지 못하고 에러가 발생하게 된다. 따라서 DBA는 이러한 정보로 각 테이블 스페이스에 속한 오브젝트 중 MAX 값보다 큰 테이블이나 인덱스가 존재한다면 해당 테이블 스페이스에 데이터파일을 추가한다거나 다음 익스턴트의 크기를 줄이기 위해 테이블과 인덱스의 NEXT 옵션을 변경해야 할 것이다.

<화면 10> 테이블 스페이스 예


또한 특정 테이블 스페이스의 물리적인 구조 중에서 가장 작은 단위인 블럭들을 그래픽하게 보여줘 해당 테이블 스페이스의 객체가 차지하고 있는 블럭의 갯수나 세그먼트 정보를 자세하게 확인할 수도 있으며, 데이터파일에 존재하는 Fragmentation도 분석해 Coalesce 과정을 수행할 수 있는데, 이 기능은 <화면 11>의 테이블 스페이스 맵을 활용해 수행할 수 있다.

<화면 11> 테이블 스페이스 예


     컨트롤 파일과 리두 로그 매니저
물리적인 데이터베이스 구조인 컨트롤 파일(Control File)과 리두 로그 파일(Redo Log File)에 대한 정보를 확인할 수 있으며, 로그 스위치(Log Switch), 리두 로그 파일 변경 작업, 아카이브 스타트/스톱(Archive Start/Stop)과 같은 특정 작업을 직접 수행할 수 있다. 컨트롤 파일은 데이터베이스의 물리적인 구조에 대한 정보를 저장하고 있으며 각 타입별로 레코드 세션(Record Section)을 사용하게 된다. <화면 12>에서의 컨트롤 파일의 상세내용을 보면 각 세션(“REDO LOG”, “DATAFILE”…)별로 최대 레코드를 갖고, 또한 사용량을 표시하는데, 만약 각 세션의 토탈 레코드들과 사용된 레코드가 동일하게 되면 더 이상 해당 세션에 대한 자원 할당을 할 수 없게 되므로 컨트롤 파일을 재생성해야 된다. 그리고 이러한 정보를 미리 확인해 대처할 수 있다.

<화면 12> 컨트롤 파일 관리


<화면 13> 칸트롤 파일과 리두 로그 매니저


Log Switch Frequency Map
<화면 14>는 하루를 1시간 그룹으로 구분해 각 시간대별로 로그 스위치의 발생 정도를 나타내어 트랜잭션 양을 파악할 수 있으며, 또한 하루 중에 가장 트랜잭션이 많은 시간대를 파악해 그 시간대에 발생할 수 있는 작업(Batch Job) 등을 다른 시간대로 변경해 수행할 수 있도록 하고 있다. Log Switch Frequency Map 기능은 현재 데이터베이스에서 발생하는 로그 스위치의 회수를 체크해 보여준다.

<화면 14> Log Switch Frequency Map


시간대별로 몇 번의 로그 스위치가 발생했는지 파악할 수 있으며 가장 많은 로그 스위치가 발생한 시간이 언제인지를 확인해 DBA로 하여금 로그 파일의 재구성과 리두 로그 버퍼의 크기에 대한 어드바이스를 받을 수 있도록 정보를 제공하고 있으며, 이를 통해 인스턴스에서 체크포인트의 발생 빈도를 예측할 수 있도록 해준다. DBA는 이 정보를 토대로 SGA 메모리의 최적화 상태를 점검할 수 있다.

Rebuild Objects
테이블 스페이스에 대한 문제를 해결하다 보면 그 안에 존재하는 특정 객체에 대해 다시 재구성해야 하는 경우가 발생한다. 테이블 스페이스 레벨에서만 문제가 해결되면 가장 좋겠지만 실제로는 데이터가 존재하는 테이블이나 인덱스 쪽에 더 무게를 둘 수밖에 없게 된다. 이 기능을 이용해 특정 테이블이나 인덱스 또는 특정 유저, 테이블 스페이스에 해당하는 객체에 대해 일괄적으로 또는 개별적으로 Rebuild 과정을 진행할 수 있다.

   Repair Chained Rows
데이터베이스의 block_size가 적거나 특정 테이블의 Row가 데이터베이스 블럭의 크기보다 큰 경우에 UPDATE 문장이 발생하는 테이블에 종종 발생되는 Chaining이나 마이그레이션이 일어나게 되는데, 이렇게 하나의 Row가 여러 블럭에 걸쳐 있으면 데이터베이스의 성능이 떨어지기 마련이다. 이 기능은 데이터베이스의 특정 테이블에서 Chaining이나 마이그레이션이 발생할 경우 해당 테이블을 분석해 Chained Row를 해결하고자 제공하는 기능이다. <화면 15>는 ‘CHAIN_TEST’ 테이블에 Chain된 Row가 약 3만 건 정도가 발생한 것인데, 화면 오른쪽에 ‘Repair’ 버튼을 누르면 Chained Row를 제거할 수 있게 된다.

<화면 15> Repair Chanined Rows


Export/Import Utility Wizard와 SQL*Loader Wizard
Export/Import Utility Wizard와 SQL*Loader Wizard는 오라클의 Export/Import 명령과 SQL*Loader를 Wizard 를 통해 쉽게 구현할 수 있도록 제공하는 기능이다. Export/Import를 이용해 일반적으로 해당 객체를 재구성하는 과정을 거치게 되는데 GUI 환경에서 누구나 손쉽게 사용할 수 있도록 제공하고 있으며, 테이블, 유저, 테이블 스페이스, 데이터베이스 모드를 모두 지원한다. 또한 SQL*Loader의 모든 기능을 지원해 컨트롤 파일을 구성할 경우 이미 지정되어 있는 많은 옵션들을 간단하게 설정할 수 있다.

Server Statistics
이 기능은 현재 인스턴스에 대해 통계 정보를 분석해 보여주며, 인스턴스 내부에 발생하는 다양한 항목들을 DBA가 확인할 수 있다.
Analysis, Waits, Latched, Session, Instance Summary 등의 5가지 탭을 통해 전체 데이터베이스의 통계 정보를 파악한다. 또한 데이터베이스에서 통계치의 값이 어떠한지에 대해 분석해 DBA에게 제시해 준다. 이를 통해 현재 통계정보의 부정확한 값들에 대한 어드바이스를 제시해 DBA로 하여금 최적의 인스턴스 상태를 유지할 수 있는 방향을 제시한다. DBA는 <화면 16>에서 빨간색으로 표시되어 있는 값들에 대해 체크해 인스턴스 환경을 수정할 수 있다.

<화면 16> Server Statistics, 데이터베이스의 대표적인 성능 지수들의 현재 값


이 외에 토드에서 지원되는 문제를 해결할 수 있는 기능을 보면 다음과 같다.

◆ Oracle Parameter and NLS Parameter : Server Statistics 기능에서 제시한 내용을 기준으로 특정 데이터베이스 파라미터를 수정할 경우, 이 기능을 사용해 쉽게 변경할 수 있다.

◆ New Database Wizard : 이 기능은 새로운 데이터베이스를 생성하기 위해 Create Database 명령을 수행하도록 하는 기능이다. DBA가 새로운 데이터베이스를 생성(create)하고자 할 경우 쉽게 GUI 환경에서 생성할 수 있도록 도와주는 위저드 기능이다.

◆ Compare Schema and Compare Database : 서로 다른 데이터베이스끼리 비교를 하거나 특정 스키마들끼리의 비교처럼 DBA가 특정 작업을 수행하기 이전과 이후에 대한 비교 작업을 수행할 경우 적용한다.

데이터베이스 브라우저 기능이란?

지금까지 DBA 기능에 대해 각 기능별로 소개를 했다. 하지만 DBA가 이 모든 기능들을 일일이 하나씩 확인한다면 이것 또한 너무 불편할 것이다.
이를 위해 토드에서는 데이터베이스 관리를 위해 필요한 내용들을 종합적으로 구성해 하나의 화면에서 확인하고 설정할 수 있도록 통합관리 체제로 관리하고 있다. 이 기능이 바로 데이터베이스 브라우저(Database Browser)이다. <화면 17>처럼 데이터베이스 브라우저는 하나의 데이터베이스를 기준으로 정보를 제공하는 것이 아니라 현재 네트워크 상에 존재하는 모든 데이터베이스를 한눈에 확인할 수 있도록 중앙집중 방식을 선택하고 있다. DBA가 A DB, B DB 등을 분산해 관리한다면 업무 효율성도 떨어질 뿐만 아니라 그로 인해 발생하는 시간과 노력에 대한 비용도 한이 없을 것이다. 데이터베이스 브라우저는 다음의 다양한 탭을 갖고 있다.

<화면 17> 데이터베이스 브라우저


◆ 데이터베이스 브라우저의 다양한 탭
- 오버뷰(Overview) : SGA 크기, Shared Pool의 크기, Hit Ratio, Event Wait 정보 확인
- 인스턴스 : 인스턴스 정보 확인
- 데이터베이스 : 데이터베이스 정보 확인
- Options : 해당 데이터베이스에 설정되어 있는 제품의 옵션 리스트 확인
- 파라미터 : 데이터베이스 파라미터 정보 확인
- 세션 : 현재 데이터베이스에 연결되어 있는 세션 정보 확인
- 탑 세션 : 현재 연결되어 있는 세션 중에서 탑 세션 리스트 확인
- RBS 액티비티 : 롤백 세그먼트의 액티비티 정보 확인
- Space Usage : 각 테이블 스페이스의 스토리지 파라미터 정보와 스페이스 정보 확인
- 데이터파일 I/O : 각 데이터파일의 토탈 사이즈, 프리 사이즈(Free Size)와 내부 블럭마다의 읽기/쓰기 회수 등에 대한 정보 확인

SQL 튜닝 엑스퍼트

SQL 튜닝 엑스퍼트는 토드의 DBA 모듈에 포함되어 있는 기능은 아니며, 토드의 엑스퍼트 튜닝 모듈(Xpert Tuning Module)에 있는 기능이다.
DBA가 시스템 퍼포먼스 튜닝만 수행하는 것이 아니라 그 안에서 동작하는 애플리케이션 튜닝에 더욱 많은 시간을 소비할 것이기 때문에 토드를 이용해 이 부분을 해결할 수 있는 방법을 제시하고자 한다. 데이터베이스를 운영하다 많이 접하게 되는 문제는 바로 잘못 작성된 SQL 문장이 될 것이다. 토드의 엑스퍼트 에디션은 현재 데이터베이스에서 잘못 작성되어 성능이 다운되는 요인이 되고 있는 SQL 문장을 찾아 가장 최적의 SQL 문장으로 바꿔주는 기능을 갖고 있다.
SQL 튜닝 엑스퍼트 기능은 SQL 에디터나 프로시저 에디터(Procedure Editor)에서 SQL 문장이나 PL/SQL 문장을 대상으로 개발시에 최적의 SQL과 PL/SQL을 만들고 싶을 경우이거나, 실행했으나 반응 시간(Response Time)이 너무 높게 나타나서 현재 환경에 맞는 최적의 문장을 만들고 싶을 경우 사용한다. 일단 SQL 에디터와 프로시저 에디터 아이콘 버튼을 실행하면 SQL 튜닝 엑스퍼트라는 화면으로 이동할 수 있다. SQL 튜닝 엑스퍼트 화면의 왼쪽에는 네비게이터 패널(Navigator Panel)이라는 것이 있는데, 이 네비게이터 패널의 순서에 따라 SQL 튜닝 과정을 진행하면 된다. 다음은 SQL 튜닝 엑스퍼트에서 SQL 튜닝 과정을 진행하는 절차이다.

1단계, SQL Detail

여기서는 SQL 에디터나 프로시저 에디터에서 수행 중인 SQL 문장을 드래그해 Execution Plan과 해당 SQL 문장에 나타난 객체의 정보를 확인할 수 있다. Execution Plan을 통해 현재 SQL 문장이 어떻게 수행될 것이지 예측할 수 있으며, 해당 테이블에 생성되어 있는 인덱스나 컬럼의 정보를 확인할 수 있다.

<화면 18> SQL Detail Window


2단계, View Advice

이 부분은 현재의 SQL 문장에 대해 Execution Plan의 정보만 갖고 튜닝 액션을 결정할 수가 없을 경우 개발자나 DBA에게 현재 환경에 적합한 가장 최적의 SQL 솔루션을 제공한다.

<화면 19> View Advice Window


- Auto Tune : 이는 오라클 옵티마이저가 판단한 근거를 기준으로 자동으로 현재 SQL 문장에 맞는 최적의 솔루션 리스트를 제공한다. 이는 튜닝 초보자에게 적합한 것으로 SQL 튜닝에 대한 지식이 없더라도 튜닝 솔루션을 찾을 수 있게 한다.

- Advice : 이는 현재 환경에 적합한 Advice List를 보여줌으로써 어느 정도 숙련된 튜너가 자기가 생각한 튜닝 솔루션과 일치하는 사항을 찾아 수행할 수 있도록 정보를 제공한다.

- Manual Tune : 토드의 SQL 튜닝 엑스퍼트에게 의존하지 않고 직접 SQL 문장을 코딩하는 경우 사용한다.

3단계, Compare Scenario

Advice에서 선택한 사항을 토대로 Original SQL 문장과 Advice SQL 문장의 Explain Plan과 SQL 문장을 기준으로 비교할 수 있도록 정보를 제공한다.

<화면 20> Compare Scenario Window


4단계, Execution Scenario

Compare Scenario 스텝까지는 직접 SQL 문장을 실행하지 않은 상태에서 간접적으로 비교를 수행한 것에 반해 이 부분은 직접 Original SQL 문장과 Advice SQL 문장을 실행해 비교할 수 있는 정보를 제공한다. 만약 Trace 정보를 만들고 싶다면 옵션으로 지정할 수도 있다.
실행 과정이 끝나면 Original SQL과 Advice SQL에 대해 그래픽하게 비교할 수 있는 그림이 나타나며 이를 통해 시각적으로 최적의 솔루션을 찾을 수 있다.

<화면 21> Advice 적용 후 성능 향상 기대치 비교


- Index Advice : 만약 View Advice 단계에서 선택한 Advice가 인덱스를 추가·삭제·변경하는 작업이었다면 이번 단계에서는 인덱스에 대한 DDL 명령을 수행해야 한다. 하지만 이를 적용했을 경우 다른 SQL 문장이 영향을 받을 수 있기 때문에 조심스럽게 접근해야 할 것이다. 따라서 실제로는 실행시에 인덱스에 대한 DDL 명령을 수행하지 않고 버추얼하게 수행해 현재 데이터베이스에 영향을 주지 않는 선에서 비교할 수 있도록 정보를 제공한다.

- Rewrite : View Advice 단계에서 선택한 Advice가 문장을 바꾸는 선에서 제공되고 있다면, 현재 Original SQL문장을 대신할 수 있는 대체 SQL 문장을 선택한 경우이다. 이를 통해 현재 과정을 진행하면 Original SQL과 Advice SQL을 전부 실제로 실행하는 과정을 거치게 된다.

- Other Advice : DDL Advice나 SQL Rewrite가 아닌 다른 내용들을 제시한 것을 선택한 경우가 해당된다.

5단계, Execution Results

실행한 내용을 토대로 그 결과를 보여주며 실행시에 생성된 통계 정보를 비교할 수 있다. 토탈 CPU, Elapsed Time, Logical Read, Physical Read 등의 많은 통계 정보를 서로 비교할 수 있다.

6단계, Best Practice

앞의 Advice에서 선택한 사항을 토대로 실제 실행과정을 거친다. 예를 들어, 인덱스 생성 Advice를 선택했다면 4번 단계에서는 가상적으로 생성해 비교를 수행했는데, 이를 비교 검토 후 적용하는 과정이라고 생각하면 된다. 또한 추가적으로 수행할 때 더 적합한 내용들이 있다면, 예를 들어 분석 작업 같은 내용이 여기에 포함될 수 있는데 최적의 상태가 될 수 있는 리스트를 제시하면 튜너는 여기에서 원하는 내용을 선택할 수 있다.

7단계, Tuning Resolution

지금까지 진행해온 모든 사항을 기본으로 해 Original SQL과 Advice SQL에 대해 어느 정도 성능 효과를 보였는지를 확인할 수 있다.

토드의 다양한 기능을 습득하기 바라며

지금까지 토드에서 제공하는 DBA 모듈에 대한 일부 기능을 소개했다. 토드라는 툴은 너무나 많은 기능들을 갖고 있기 때문에 사용자의 입장에서 어떤 기능들이 토드에 있는지조차 모르는 경우가 다반사라고 생각한다. 이렇게 토드에는 숨겨진 많은 기능들이 독자의 업무에 도움이 될 수 있으면 하는 바람이다.

제공 : DB포탈사이트 DBguide.net

출처명 : 마이크로소프트웨어[2004년10월호

[출처] toad 숨은 기능 ~ |작성자 에러


반응형
반응형
Oracle C++ Call Interface (OCCI) is an Application Programming Interface (API) that provides C++ applications access to data in an Oracle database. This API is a significant improvement to the Oracle Call Interface (OCI) API as far as ease of use is concerned. Engineers who have written JDBC (Java Database Connectivity) code will find the OCCI API to be quite similar to that of JDBC

1) The table that is used in the example code is:

Code: SQL
CREATE TABLE EMP(
    empno     NUMBER,
    ename     VARCHAR2(10),
    hireDate  Date);
2) Database Query : Select the contents of the EMP table

Code: Cpp
#include <DbManager.h>
#include <iostream>

using namespace std;

using namespace oracle::occi;

const string sqlString("select empno, ename, hiredate from emp");

const string dateFormat("DD-MON-YYYY HH24:MI:SS");

int main(int argc, char **argv)

{
    if (argc != 2)
    {
        cerr << "\nUsage: " << argv[0] << " <db-user-name>\n" << endl;
        exit(1);
    }
   
    // Initialize OracleServices
   
    DbManager* dbm = NULL;
   
    OracleServices* oras = NULL;
   
    Statement *stmt = NULL;
   
    ResultSet *resultSet = NULL;
   
    try
    {
       
        // Obtain OracleServices object with the default args.
       
        dbm = new DbManager(userName);
       
        oras = dbm->getOracleServices();
       
        // Obtain a cached connection
       
        Connection * conn = oras->connection();
       
        // Create a statement
       
        stmt = conn->createStatement(sqlString);
       
        int empno;
       
        string ename;
       
        Date hireDate;
       
        string dateAsString;
       
        // Execute query to get a resultset
       
        resultSet = stmt->executeQuery();
       
        while (resultSet->next())
        {
           
            empno = resultSet->getInt(1)// get the first column returned by the query;
           
            ename = resultSet->getString(2)// get the second column returned by the query
           
            hireDate = resultSet->getDate(3)// get the third column returned by the query
           
            dateAsString="";
           
            //You cannot check for null until the data has been read
           
            if (resultSet->isNull(1))
            {
                cout << "Employee num is null... " << endl;
            }
            if (resultSet->isNull(2))
            {
                cout << "Employee name is null..." << endl;
            }
            if (resultSet->isNull(3))
            {
                cout << "Hire date is null..." << endl;
            }
            else
            {
                dateAsString=hireDate.toText(dateFormat);
            }
            cout << empno << "\t" << ename << "\t" << dateAsString << endl;
           
        }
       
        // Close ResultSet and Statement
       
        stmt->closeResultSet(resultSet);
       
        conn->terminateStatement(stmt);
       
        // Close Connection and OCCI Environment
       
        delete dbm;
       
    }
    catch (SQLException& ex)
    {
        if (dbm != NULL)
        {
            dbm->rollbackActions(ex, stmt, resultSet); // free resources and rollback transaction
        }
    }
    catch (ExoException& ex1)
    {
        cerr << "\nCaught ExoException:\n" << ex1.getExceptionText() << endl;
        exit(2);
    }
   
    return 0;
}

반응형

+ Recent posts