//-- 원문출처: http://www.dba-oracle.com/t_impdp_transform_segment_attributes.htm 

//-- impdp transform=segment_attributes

//-- Oracle Database Tips by Donald BurlesonFebruary 22, 2015 


impdp transform=segment_attributes

Oracle Database Tips by Donald BurlesonFebruary 22, 2015

Question:  What does the impdp transform parameter do?  I read about thetransform=segment_attributes:n:table argument in the docs.

Answer:  Oracle data pump import (impdp) provides the transform=segment_attributes argument to allow you to change object DDL for specific objects (table, indexes), and remove just about everything from the DDL but the basic column definitions.

If the value is transform=segment_attributes:y (the default), then segment attributes (file attributes, storage parameters, tablespaces, and logging) are included in the import (impdp, with the DDL for the specified object types.

For example, if you wanted to use the default tablespace parameters for the imported DDL, you could include:

root>  impdp scott/tiger transform=segment_attributes:n:tables

This example would import only the "basic" DDL for all table DDL in the dmp file, omitting the storage clause, tablespace specification and datafiles parameters, allowing the system-wide defaults to be used.  This is useful when you don't want to have to pre-create all of the table definitions and import with ignore=y.

In another example, assume that you only wanted to omit the storage clauses for all tables:

root>  impdp scott/tiger transform=segment_attributes:storage:n

You can also use the impdp transform=segment_attributes:n is used with other arguments such as remap_tablespace  to change the tablespace names for all table in the import dmp file.  For example, the following directs the import (impdp) to ignore the existing tablespace specifications and re-map the tablespace names:

root>  impdp scott/tiger transform=segment_attributes:n remap_tablespace=users:prodts

You can also combine transform=segment_attributes parameters to perform multiple operations on the dmp file DDL. 

root>  impdp scott/tiger transform=SEGMENT_ATTRIBUTES:n:table,STORAGE:N:table



  OS 의 Oracle Account 를 획득한 경우, sqlplus 로 접속해서 ?/rdbms/admin/awrrpt.sql 을 수행하면 되겠지만, OS 계정을 사용할 수 없는 경우에도, DB User 를 사용할 수 있고, 필요한 권한이 있다면 AWR Report 를 뽑아볼 수 있다.



1. DBMS_WORKLOAD_REPOSITORY 일반


  - Oracle 에서 AWR Snapshot 관리 편의를 위해 제공하는 Package  

  - 주로 사용되는 Snapshot 관리 방법

 항목

명령어 

 AWR Snapshot

 설정 변경


 DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS

 ( [RETENTION => retention_time], [INTERVAL => interval_time], [TOPNSQL => topn_sql_number] ) ;


 AWR Snapshot 

 삭제


 DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHO_RANGE

 ( LOW_SNAP_ID => snap_id, HIGH_SNAP_ID => snapid [DBID => dbid] ) ;


Baseline 

생성


 PROCEDURE create_baseline(start_snap_id  IN NUMBER,
                                      end_snap_id    IN NUMBER,

                                      baseline_name  IN VARCHAR2,

                                      dbid           IN NUMBER DEFAULT NULL,

                                      expiration     IN NUMBER DEFAULT NULL ) ;


Baseline 
이름변경


 PROCEDURE rename_baseline(old_baseline_name IN VARCHAR2,
                                        new_baseline_name IN VARCHAR2,
                                        dbid              IN NUMBER DEFAULT NULL ) ;

  - DBMS_WORKLOAD_REPOSITORY 에 대해서는 Manual 에 자세히 기술됨



2. DBMS_WORKLOAD_REPOSITORY 로 AWR Report 조회


  A. 필요한 권한 및 명령어


  - 필요권한 : DBMS_WORKLOAD_REPOSITORY 실행, select any dictionary 등 (Privilege 부족 시 ORA-06550 등 발생)     

  - DBID 등은 dba_hist_snapshot 에서 조회

 SQL> select * from dba_hist_snapshot order by begin_interval_time desc ;


  - 주로 사용되는 AWR Report 조회 방법

 항목

명령어 

 AWR Report 

 Text Format


 DBMS_WORKLOAD_REPOSITOR.AWR_REPORT_TEXT

 ( :DBID, :INST_ID, :BEGIN_SNAP, :END_SNAP ) ;


  -- 이하 참조

  FUNCTION awr_report_text(l_dbid     IN NUMBER,

                                      l_inst_num IN NUMBER,

                                      l_bid      IN NUMBER,

                                      l_eid      IN NUMBER,

                                      l_options  IN NUMBER DEFAULT 0)

  RETURN awrrpt_text_type_table PIPELINED;


 AWR Report 

 html Format


 DBMS_WORKLOAD_REPOSITOR.AWR_REPORT_HTML

 ( :DBID, :INST_ID, :BEGIN_SNAP, :END_SNAP ) ;


  -- 이하 참조


  FUNCTION awr_report_html(l_dbid     IN NUMBER,

                                      l_inst_num IN NUMBER,

                                      l_bid      IN NUMBER,

                                      l_eid      IN NUMBER,

                                      l_options  IN NUMBER DEFAULT 0)

  RETURN awrrpt_html_type_table PIPELINED;



  B. AWR Report 조회 셈풀


    B-1. html format 


  -- 실행 셈풀 : 조회



  -- 실행 셈풀 : 결과값



  --  실행 셈풀 : AWR Report <- Copy & Past 로 새로운 html 화일을 생성



    B-2. text format 


  -- 실행 셈풀 : 조회



  -- 실행 셈풀 : 결과값




//-- 이 내용은 Eegloos 의 블루오션 [BLUE OCEAN] 에서 "장땡" 님 글을 그대로 가져 왔습니다.

//-- 블루오션 원문 링크는 http://repository.egloos.com/5790800 입니다.

//-- 아래 "recover database until cancel ; " 를 수행하기 위해서는 Archive Log Mode 이여야 합니다.  

1. 현상


$ lsnrctl start
$ sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 18 10:24:27 2014

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> startup
ORACLE instance started.

Total System Global Area 2.6991E+10 bytes
Fixed Size                  2213976 bytes
Variable Size            1.9059E+10 bytes
Database Buffers         7784628224 bytes
Redo Buffers              145174528 bytes
Database mounted.
ORA-03113: end-of-file on communication channel
Process ID: 25292
Session ID: 177 Serial number: 3


2. 확인 및 조치사항


# startup단계를 하나하나 실행하여 어디가 문제인지 확인한다.
SQL> startup nomount;
SQL> alter database mount;
SQL> alter database open; ==> 여기서 에러가 발생했다.
alter database open
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 24832
Session ID: 177 Serial number: 1

# aleter databse mount이후에 아래 명령어를 실행한다.
SQL> recover database until cancel ;
Media recovery complete.
SQL> alter database open resetlogs ;
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 2.6991E+10 bytes
Fixed Size                  2213976 bytes
Variable Size            1.9059E+10 bytes
Database Buffers         7784628224 bytes
Redo Buffers              145174528 bytes
Database mounted.
Database opened.
SQL>

* database open실 발생하는 원인은 다음과 같은데
  위 사항은 1)번 사항이다.
 1) DATA파일이 깨졌을 때
 2) SN번호 불일치 시 -> "SCN 번호 불일치" 의 오타로 보임
 3) DB의 컨트롤 파일문제 시
 4) 설정파일 오류

3. 추가사항

DB에 문제가 생겨서 강제로 kill로 죽였을 때 
$ sqlplus "/as sysdba"로 접속하여
$ startup하면 ORA-01012: not logged on 에러가 발생한다.
그때는 SQL> startup force로 실행한다.




1. DB Instance 의 Archive Log Mode 초기구성 결과 on 11gR2 


  -- 현재 설정 내용

 

 SQL> connect /as sysdba

 Connected.

 SQL> archive log list 

 Database log mode              No Archive Mode

 Automatic archival             Disabled

 Archive destination            USE_DB_RECOVERY_FILE_DEST

 Oldest online log sequence     36

 Current log sequence           38

 SQL>  



2. Archive Destination 을 LOG_ARCHIVE_DEST_1 로 변경 


  -- fast_recovery_area 에 Archive Log 를 떨어 뜨리지 않기 위해서 등등....


 SQL> alter system set LOG_ARCHIVE_START = TRUE scope=spfile ;      

 SQL> alter system set LOG_ARCHIVE_FORMAT = 'DAPPE02_%r_%T_%S.arc' scope=spfile ; 

 SQL> alter system set LOG_ARCHIVE_DEST = '' scope = spfile ; 

 SQL> alter system set LOG_ARCHIVE_DEST_1 = 'location=/u02/arch/DAPPE02' scope = spfile ; 


 -- DB Instance 재가동이 필요

 SQL> shutdown immediate ; 

 SQL> startup mount ; 

 SQL> alter database archivelog ; 

 SQL> alter database open ;



3. 재가동 후 변경 내용 확인


  -- 항상, 확인은 필요하다.


 SQL> archive log list ;

 Database log mode              Archive Mode

 Automatic archival             Enabled

 Archive destination            /u02/arch/DAPPE02

 Oldest online log sequence     36

 Next log sequence to archive   38

 Current log sequence           38

 SQL> 


  -- 아래의 File name 처럼 생성된다. : 포맷은 위에서 'DAPPE02_%r_%T_%S.arc' 설정 했음 => 지금 보니, 굳이 자리수를 맞출 필요 없이 %T 은 %t 로 했었어도 좋았을 것을...


 oraapp112@mwapp:/u02/arch/DAPPE02] ls -al 

 drwxr-xr-x 2 oraapp121 dba     4096 Aug 10 13:33 .

 drwxrwxr-x 4 oraapp112 dba     4096 Aug 10 13:28 ..

 -rw-r----- 1 oraapp121 dba 15956480 Aug 10 13:33 DAPPE02_919102183_0001_0000000038.arc

 -rw-r----- 1 oraapp121 dba     1024 Aug 10 13:33 DAPPE02_919102183_0001_0000000039.arc

 oraapp112@mwapp:/u02/arch/DAPPE02] 






//-- DB 11gR2 Silent Install Script : Short Guide


1. DB 엔진설치 


  -- 설치파일 준비


 oraapp112@mwapp:/home/oraapp112/media] unzip p13390677_112040_Linux-x86-64_1of7.zip

 oraapp112@mwapp:/home/oraapp112/media] unzip p13390677_112040_Linux-x86-64_2of7.zip 


  -- response 파일 수정


 oraapp112@mwapp:/home/oraapp112/media/database/response] cp -p db_install.rsp db_install.rsp.orig

 oraapp112@mwapp:/home/oraapp112/media/database/response] vi db_install.rsp 

    >> 수정 사항 참조 : 일부 Default Value 도 표기

 oracle.install.option=INSTALL_DB_SWONLY

 ORACLE_HOSTNAME=mwapp

 INVENTORY_LOCATION=/u02/oracle/oraInventory_112

 SELECTED_LANGUAGES=en,ko

 ORACLE_HOME=/u02/oracle/product/11.2.0/db

 ORACLE_BASE=/u02/oracle

 oracle.install.db.InstallEdition=EE

 oracle.install.db.EEOptionsSelection=true

 oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0

 oracle.install.db.DBA_GROUP=dba

 oracle.install.db.OPER_GROUP=dba

 oracle.install.db.config.starterdb.type=GENERAL_PURPOSE

 DECLINE_SECURITY_UPDATES=true


  -- Silent 로 DB엔진 설치


oraapp112@mwapp:/home/oraapp112/media/database] ./runInstaller -silent -responseFile /home/oraapp112/media/database/response/db_install.rsp 


 As a root user, execute the following script(s):

        1. /u02/oracle/product/11.2.0/db/root.sh


 Successfully Setup Software.    ==> 이렇게 나오면, 엔진이 정상설치 된 것 

    


2. 적절한 PUS 적용


  -- OPatch Update : 생략, 다시 확인 6880880

  -- 적절한 PSU Apply : 생략, 2016년도 어느 때부터 날자로 출시.



3. Listener 구성


  -- response 파일 수정


 oraapp112@mwapp:/home/oraapp112/media/database/response] cp -p netca.rsp netca.rsp.orig

 oraapp112@mwapp:/home/oraapp112/media/database/response] vi netca.rsp 

    >> 수정 사항 참조 : 일부 Default Value 도 표기

 RESPONSEFILE_VERSION="11.2"

 CREATE_TYPE="CUSTOM"

 LOG_FILE=""/home/oraapp112/media/database/response/netca_inst.log""

 LISTENER_NAMES={"LISTENER_DAPPE01"}

 LISTENER_PROTOCOLS={"TCP;1621"}

 LISTENER_START=""LISTENER_DAPPE01""

 NSN_PROTOCOLS={"TCP;HOSTNAME;1621"} 


  -- Silent 로 DB Listener 구성


 oraapp112@mwapp:/home/oraapp112/media/database/response] cd $ORACLE_HOME/bin 

 oraapp112@mwapp:/u02/oracle/product/11.2.0/db/bin] ./netca -silent -responseFile /home/oraapp112/media/database/response/netca.rsp 



4. DB Instance 생성


  -- response 파일 수정


 oraapp112@mwapp:/home/oraapp112/media/database/response] cp -p dbca.rsp dbca.rsp.orig

 oraapp112@mwapp:/home/oraapp112/media/database/response] vi dbca.rsp 

    >> 수정 사항 참조 : 일부 Default Value 도 표기

RESPONSEFILE_VERSION = "11.2.0"

 OPERATION_TYPE = "createDatabase"

 GDBNAME = "DAPPE01"

 SID = "DAPPE01"

 SYSPASSWORD = "Customized_Password"

 SYSTEMPASSWORD = "Customized_Password"

 SYSMANPASSWORD = "Customized_Password"

 DATAFILEDESTINATION = "/u02/data01/oradata"

 STORAGETYPE=FS

 CHARACTERSET = "KO16MSWIN949"

 NATIONALCHARACTERSET= "AL16UTF16"

 SAMPLESCHEMA=TRUE

 AUTOMATICMEMORYMANAGEMENT = "TRUE"

 TOTALMEMORY = "2048"

    # 일단은, AMM 을 활성화 하고, 최소 메모리로 DB Instance 를 생성, DB SID 와 CHARACTERSET 에 주의


  -- Silent 로 Instance 생성


 oraapp112@mwapp:/home/oraapp112/media/database/response] cd $ORACLE_HOME/bin

 oraapp112@mwapp:/u02/oracle/product/11.2.0/db/bin] ./dbca -silent -responseFile /home/oraapp112/media/database/response/dbca.rsp



5. 추가사항


  -- root.sh 수행 잊지 말기 : 엔진 설치 후, DB Instance 구성 후

  -- 여러가지 구성을 대비?해서, oraInventory 와 diag 를 unique 하게 생성~ 나중에 file name 이 unique 해서 폴더 병합이 번거로워짐..  




1. 현상


  - DB12c 이상에서, 특정 Column 에 대한 rename column 혹은 drop column 시, ORA-54032 와 함께 변경이 안됨


SQL> alter table OWNER.AG_NB_RD_SBAS_DD_SUM rename column MRD_STAT_CD to REP_POL_STAT_CD ; 

수행 시,, 아래 Message 를 출력 

"ORA-54032: column to be renamed is used in a virtual column expression"

"ORA-54033: column to be modified is used in a virtual column expression"



2. 원인


  - 해당 컬럼이 virtual column 에 포함되어 있어서 변경이 안됨

  - DB12c 이상 에서는, extended statistics 기능을 위해, 사용자가 생성하지 않은 컬럼도 DB 엔진이 virtual column 으로 지정해 별도 생성, 관리

  - extended statistics 에 대해서 기술된 내용 : This feature enables to Oracle calculate statistics on a group of columns. It uses this information to improve row estimates. This is useful when there's a correlation between the values of two (or more) columns in a table.

  - SYS_OP_COMBINED_HASH 은 an undocumented feature 라고 합니다. The name implies Oracle is merging the arguments together to form a hash 라고 기술되어 있습니다.

  

  - 확인 방법

SQL> select OWNER, table_name, column_name, data_type, hidden_column, data_default

        from dba_tab_cols

        where table_name ='해당_TABLE_NAME' and virtual_column = 'YES'

  # data_default 에 해당 column 이 포함되어 있다면, ORA-54032, ORA-54033 와 함께 변경이 안됨


  - 확인 결과 (셈풀)

COLUMN_NAME                 DATA_DEFAULT        HIDDEN_COLUMN

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

SYS_STUYPW88OE302TFVBNC6$MMQXE SYS_OP_COMBINED_HASH("X","Y") YES

Z                                                                                         NO

Y                                         NO

X                                         NO 

  # 위와 같이 조회 되는 경우, X 와 Y 의 2개 Column 은 SYS_OP_COMBINED_HASH 에 속한 virtual column 이 됩니다.



3. 조치방법


  3-A. 해당 extended statistics 컬러을 삭제


  - 아래 Package 를 통해 삭제 가능


SQL> exec dbms_stats.drop_extended_stats( ownname => 'OWNER', tabname => '해당_TABLE_NAME', extension => '("BASE_YM","MRD_STAT_CD","MRD_PROD_CD")' ) ;

  혹은

SQL> exec dbms_stats.drop_extended_stats(OWNER, '해당_TABLE_NAME', '(BASE_YM, MRD_STAT_CD, MRD_PROD_CD)');


  - 아래 Package 를 통해 생성 가능 (필요하다고 판단할 경우, DB 가 다시 생성)


SQL> exec dbms_stats.create_extended_stats( ownname => 'OWNER', tabname => '해당_TABLE_NAME', extension => '("BASE_YM","MRD_STAT_CD","MRD_PROD_CD")' ) ;


  3-B. 해당 Table 을 재생성 : 재생성 데 따른 제약은 없습니다. 


SQL> alter table OWNER.AG_NB_RD_SBAS_DD_SUM drop primary key cascade ;  

SQL> drop table OWNER.AG_NB_RD_SBAS_DD_SUM cascade constraints ;

 

SQL> create table OWNER.AG_NB_RD_SBAS_DD_SUM ( ------  생략  ) ;



ps. 이 내용은 다음 URL을 참조하였습니다 : https://blogs.oracle.com/sql/entry/ora_54033_and_the_hidden 

+ Recent posts