반응형

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
 <title>RSS 리더기</title>


 <script type="text/javascript">
 // Control
  var txtTimer;
  var lblTimer;
  var refreshTime;
  var rssList;
  var last_modif;

  function timerSet(){
   refreshTime = parseInt(txtTimer.value);

   if(isNaN(refreshTime)){
    alert("숫자기입바람");
    txtTimer.value="";
    txtTimer.focus();
    return;
   }
   lblTimer.replaceChild(document.createTextNode(refreshTime), lblTimer.firstChild );
   refreshXML();
  }

  function refreshXML(){
   clearTimeout(refreshXMLTimer);
   doParse();
   var refreshXMLTimer = setTimeout("refreshXML()", refreshTime*60000 );
   last_modif.replaceChild(document.createTextNode(new Date()), last_modif.firstChild );
  }

  window.onload = function(){
   txtTimer = document.getElementById("txtTimer");
   lblTimer = document.getElementById("lblTimer");
   rssList = document.getElementById("rssList");
   last_modif = document.getElementById("last_modif");
   //timerSet();
   document.getElementById("sendButton").onclick = function (){
    timerSet();
   }
  }


 // RSS Request관련.
  var rssDoc;
  function doParse(){
   if (document.implementation && document.implementation.createDocument){
    try{
     netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
     netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
     netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
    }catch(e){alert(e);}

    rssDoc = document.implementation.createDocument("", "", null);
    rssDoc.async = false;
   } else if (window.ActiveXObject) {
    rssDoc = new ActiveXObject("Microsoft.XMLDOM");
    rssDoc.async = true;
    rssDoc.onreadystatechange = function (){
     if (rssDoc.readyState != 4) return false;
     rssDocLoad();
     return true;
    }
   } else {
    alert("미지원 브라우져....");
   }

   try{
    var rssAddr = document.getElementById("rssAddr");
    rssDoc.load(rssAddr.value)

    if(rssDoc.readyState==null) rssDocLoad();
   } catch(e) {
    alert(e);
    return;
   }
  }

  function rssDocLoad(){
   tableReset();
   
   var rssTitle = document.getElementById("rssTitle");
   var rssDocsTitle = rssDoc.getElementsByTagName("title").item(0).firstChild.nodeValue;
   var rssDocsLink = rssDoc.getElementsByTagName("link").item(0).firstChild.nodeValue;

   var aEl = document.createElement("a");
   var hrefAttr = document.createAttribute("href");
   hrefAttr.value = rssDocsLink;
   aEl.setAttributeNode(hrefAttr);
   aEl.appendChild(document.createTextNode(rssDocsTitle));
   aEl.target ="_blank";
   rssTitle.replaceChild(aEl, rssTitle.firstChild);


   var itemNode = rssDoc.getElementsByTagName("item");
   var lblProgress = document.getElementById("lblProgress");
   var tbodyEl = document.createElement("tbody");
   
   for(i=0; i<itemNode.length; i++){
    removeWhiteSpace(itemNode[i]);

    var title = "";
    var link = "";
    var description = "";
    var pubDate = "";
    var author = "";
    var category = "";

    for(ix=0; ix<itemNode[i].childNodes.length; ix++){
     var curNode = itemNode[i].childNodes[ix];
     var curNodeVal = curNode.firstChild.nodeValue;
     switch( curNode.tagName ){
      case "title":
       title = curNodeVal;
       break;
      case "link":
       link = curNodeVal;
       break;
      case "description":
       description = curNodeVal;
       break;
      case "author":
       author = curNodeVal;
       break;
      case "category":
      case "dc:subject":
       category = curNodeVal;
       break;
      case "pubDate":
      case "dc:date":
       pubDate = curNodeVal;
       break;
      default:
     }

    }

    var trEl = document.createElement("tr");
    var tdEl;

    tdEl = document.createElement("td");
    tdEl.appendChild(
     document.createTextNode(pubDate.substring(0,10)) );
    trEl.appendChild(tdEl);

    tdEl = document.createElement("td");
    tdEl.appendChild(
     document.createTextNode(title));
    trEl.appendChild(tdEl);

    tdEl = document.createElement("td");
    tdEl.appendChild(
     document.createTextNode(author));
    trEl.appendChild(tdEl);

    tdEl = document.createElement("td");
    var aEl = document.createElement("a");
    var hrefAttr = document.createAttribute("href");
    hrefAttr.value = link;
    aEl.setAttributeNode(hrefAttr);
    aEl.appendChild(document.createTextNode("열기"));
    aEl.target ="_blank";
    tdEl.appendChild(aEl);
    trEl.appendChild(tdEl);

    tdEl = document.createElement("td");
    tdEl.appendChild(
     document.createTextNode(category));
    trEl.appendChild(tdEl);

    tbodyEl.appendChild(trEl);
   }
   rssList.appendChild(tbodyEl);
  }

  function removeWhiteSpace(nodeList){
   var notWhitespace = /\S/
   for (var rwi=0; rwi<nodeList.childNodes.length; rwi++){
    if ((nodeList.childNodes[rwi].nodeType == 3)&&
     (!notWhitespace.test(nodeList.childNodes[rwi].nodeValue))) {
     nodeList.removeChild(nodeList.childNodes[rwi])
     rwi--;
    }
   }
  }

  function tableReset(){
   // 제목만 있다면 지우지 않는다.
   if(rssList.childNodes.length==1) return;

   for(var tri=1; tri<rssList.childNodes.length; tri++){
    rssList.removeChild(rssList.childNodes[tri]);
    tri--;
   }
  }

 </script>
 <style type="text/css">
  table.mainTbl {
   border:1px solid blue;
   background-color:#eaeafa;
   width: 100%;
  }

  table.mainTbl td{
   padding:8px 4px 4px 4px;
  }

  table.mainTbl td.header{
   font-weight:bold;
   border-bottom: 1px solid gray;
  }
  input {
   border:1px solid gray;
   padding: 1px 1px 1px 1px;
  }
 </style>
  </head>
  <body>
 <form action=" ">
        RSS주소: <input type="text" name="rssAddr" id="rssAddr" style="width:350px"/><input type="button" id="sendButton" value="가져오기"/><br/>
 체널: <span id="rssTitle">&nbsp;</span>&nbsp;&nbsp;&nbsp;<br/><br/>
 새로고침은 <input
  type="text" value="1" name="txtTimer" id="txtTimer" style="width:20px"/>분 단위로<input
  type="button" id="btnSet" name="btnSet" value="설 정" onclick="timerSet()"/> (현재 <span id="lblTimer">&nbsp;</span>분 단위로)<br/>
  마지막 읽은 시간 : <span id="last_modif">&nbsp;</span>
 <br/><br/>
 <input type="button" value="새 로 고 침" style="margin-bottom:10px" onclick="javascript:refreshXML();"/>

 <table class="mainTbl" cellpadding="0" cellspacing="0" id="rssList"><tr>
  <td class="header">날짜</td>
  <td class="header">제목</td>
  <td class="header">글쓴이</td>
  <td class="header">원본링크</td>
  <td class="header">카테고리</td>
 </tr></table>
 <br/>
 <div style="text-align:center">by visharp (in <a href="http://okjsp.pe.kr" target="_blank">okjsp.pe.kr</a>)</div>
 </form>
  </body>
</html>

Posted by 1010
02.Oracle/DataBase2008. 7. 7. 17:37
반응형

select * from sb???? as of timestamp(systimestamp - interval '120' minute) where pername='홍길동';


insert into sb????
select * from sb???? as of timestamp(systimestamp - interval '120' minute) where perid='660729';




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




오라클에서 지원하는 Flashback 이라는 기능입니다.


select

select * from item

 where orgid ='HANSALIM'  and itemnum like 'R %' ;


delete
 

 delete from item

 where orgid ='HANSALIM'  and  itemnum like 'R %';


commit

commit;

 

delete 한것을 다시 조회해 온다 (10분 전내용으로)

 SELECT * FROM item

 as of timestamp ( systimestamp - interval '10' minute)

where orgid ='HANSALIM'  and  itemnum like 'R %';


원래 table로 다시 인서트 한다.
 

insert into item

 SELECT * FROM item

 as of timestamp ( systimestamp - interval '10' minute)

where orgid ='HANSALIM'  and  itemnum like 'R %';

※ update 잘못친경우도 10분전(interval '10' minute) 여기 시간을 조정해서 읽어온 후 처리 할수도 있습니다.

참고문서

http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_flashback.htm#sthref1460 

Posted by 1010
98..Etc/Etc...2008. 7. 7. 17:32
반응형
[스크랩] [엑셀] 주민등록번호 뒷자리 ******로 채우기
조회(12)
콤퓨터관련 | 2008/01/30 (수) 21:08
공감하기(0) | 스크랩하기(0)
오늘은 엑셀 묻고 답하기 게시판에 [ryujoo]님의 질문에 대해 [khan..]님이 답변한 내용을 소개합니다.

(엑셀 묻고 답하기 게시물 번호: 46251, 사용버전: Excel 2003)
[질문]주민등록번호 DATA의 숫자들 중 뒷자리 6개의 숫자를 ‘*’으로 표시 할 수 있나요?
ex) 123456-1234567를 123456-1****** 으로 표시하려고 합니다.

또, 한 셀에 두 개의 주민등록번호가 있을 경우도 있습니다. 이럴 경우에도 적용 가능한 방법 좀 부탁 드립니다.
[답변]IF, LEN, REPLACE, SEARCH 함수를 이용하여 다음과 같은 수식을 사용합니다.

=IF(LEN(B2)>15,REPLACE(REPLACE(B2,SEARCH("-",B2)+2,6,"******"),SEARCH("-",B2,8)+2,6,"******"),REPLACE(B2,SEARCH("-",B2)+2,6,"******"))
  STEP> 따라하기

아래와 같이 가상의 주민등록번호가 입력되어 있다고 가정하겠습니다.
<1> 한 셀에 입력된 한 개 또는 그 이상의 주민등록번호의 뒷자리 6개의 숫자를 ‘*’기로 대신 표시하기 위해서 B1셀에 다음과 같은 수식을 입력합니다.
=IF(LEN(A1)>15,REPLACE(REPLACE(A1,SEARCH("-",A1)+2,6,"******"),SEARCH("-",A1,8)+2,6,"******"),REPLACE(A1,SEARCH("-",A1)+2,6,"******"))
<2> B1셀에 다음과 같이 결과가 표시됩니다.
<3> B1셀의 수식을 자동 채우기 기능을 이용하여 B5셀까지 복사합니다.
[풀이]
LEN함수를 이용하여 한 셀에 주민등록번호가 1개가 입력되어 있는지, 2개가 입력되어 있는지 구분합니다.
입력된 데이터의 길이가 15자리 이하인 경우에는 REPLACE 함수를 한번 이용하여 뒷자리 6개의 숫자를 ‘*’로 바꿔주고, 15자리 이상인 경우에는 REPLACE 함수를 2번 이용하여 작업을 두 번 수행합니다.
이때 SEARCH함수를 살펴보면 SEARCH("-",A1,8)+2,6,"******")라고 하여 8번째 이후에 입력된 ‘-’의 위치를 반환하도록 되어 있습니다.
[참고] 함수
함수명 설   명
REPLACE 지정한 문자 수에 따라 문자열의 일부를 다른 문자열로 바꿉니다.
[형식] REPLACE(old_text,start_num,num_chars,new_text)
Old_text: 바꾸려는 문자열입니다.
Start_num: old_text에서 바꿀 문자의 위치입니다.
Num_chars: REPLACE가 old_text에서 new_text로 바꿀 문자열의 수입니다.
New_text: old_text에 바꾸어 넣을 새 문자열입니다
[예] REPLACE(A1,2,6,"******")
입력: A1=> 1111111
결과: 1******
해설: A1셀에 입력된 데이터의 2번째 자리부터 6개를 ‘*’로 바꿔줍니다.
SEARCH start_num부터 시작하여 특정 문자 또는 텍스트 문자열이 처음 발견되는 문자의 위치를 반환합니다
[형식] SEARCH(find_text,within_text,start_num)
Find_text: 찾고자 하는 텍스트입니다. find_text에 와일드카드 문자인 물음표(?)와 별표(*)를 사용할 수 있습니다. 물음표는 한 문자에 해당하고 별표는 일련의 문자에 해당합니다. 실제 물음표나 별표를 찾으려면 문자 앞에 물결표(~)를 입력합니다.
within_text: find_text를 찾으려는 텍스트입니다.
start_num: within_text에서 찾기 시작할 문자의 위치입니다.
[예] SEARCH("-",A1)
입력: A1셀=> 123456-1234567
결과: 7
해설: A1셀에 입력된 데이터에서 ‘-’위치를 알려줍니다.
LEN 문자열의 문자 수를 구합니다
[형식] LEN(text)
Text: 길이를 알려는 문자열로서 공백도 문자로 계산됩니다.
[예] LEN(A1)
입력: A1셀=> 123456-1234567
결과: 14
해설: A1셀에 입력된 문자열의 문자 수를 계산하여 줍니다.
 
출처 : 오피스 튜터
원본 : [엑셀] 주민등록번호 뒷자리 ******로 채우기
Posted by 1010
02.Oracle/DataBase2008. 7. 7. 17:30
반응형
 

imp user/pass

file=xxxx.dmp                                       // 파일명 적으시오

full=y                                                    // 없어두 됨

ignore=y                                                // 없어두 됨

commit=y                                                // 없어두 됨

fromuser=(dmp파일 만든 장본인 계정)

touser=(import 받을 계정)

tables=tbl1,tbl2                                    // 뽑아내고 싶은 테이블이 있다면...

 

ex) $imp system/manager file=source.dmp fromuser=batman touser=robin tables=list

Posted by 1010
02.Oracle/DataBase2008. 7. 7. 17:29
반응형

===================================================================

1. jakarta 홈피에서 dbcp 관련 jar 를 다운 받는다.


여기 - > http://ftp.apache-kr.org/jakarta/commons


commons-collections-3.1.jar

commons-dbcp-1.2.1.jar

commons-pool-1.2.jar


===================================================================

2. ${WAS_HOME}/common/lib 에 위치 시키고 classespath 를 확인한다.


===================================================================

3. Init ( DBCPInit.java ) 파일 생성


    package com.zzang.db;

    import javax.servlet.http.HttpServlet;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import java.util.StringTokenizer;

    public class DBCPInit extends HttpServlet {

        public void init(ServletConfig config) throws ServletException {
            try {
                String drivers = config.getInitParameter("jdbcdriver");
                StringTokenizer st = new StringTokenizer(drivers, ",");
                while (st.hasMoreTokens()) {
                    String jdbcDriver = st.nextToken();
                    Class.forName(jdbcDriver);
                }

                Class.forName("org.apache.commons.dbcp.PoolingDriver");

                System.setProperty("org.xml.sax.drvier",
                       "org.apache.crimson.parser.XMLReaderImpl");
            } catch(Exception ex) {
                throw new ServletException(ex);
            }
        }
    }


===================================================================

4. web.xml 설정 하기

${WAS_HOME}/webapps/ROOT/WEB-INF/web.xml


<!-- DBCP config  start -->
  <servlet>
     <servlet-name>DBCPInit</servlet-name>
     <servlet-class>com.zzang.db.DBCPInit</servlet-class>
     <load-on-startup>1</load-on-startup>
     <init-param>
        <param-name>jdbcdriver</param-name>
        <param-value>oracle.jdbc.driver.OracleDriver</param-value>
     </init-param>
  </servlet>

<!-- DBCP config  end -->


===================================================================

5. config 파일 생성

${WAS_HOME}/webapps/ROOT/WEB-INF/classes/pool.jocl


<object class="org.apache.commons.dbcp.PoolableConnectionFactory" xmlns="http://apache.org/xml/xmlns/jakarta/commons/jocl">

        <object class="org.apache.commons.dbcp.DriverManagerConnectionFactory">
        <string value="jdbc:oracle:thin:@localhost:1521:ora92" />
        <string value="userid" />
        <string value="userpw" />
        </object>

      <object class="org.apache.commons.pool.impl.GenericObjectPool">
        <object class="org.apache.commons.pool.PoolableObjectFactory" null="true" />
        <int value="10" />  <!-- maxActive -->
        <byte value="1" />  <!-- whenExhaustedAction -->
        <long value="20000" /> <!-- maxWait -->
        <int value="100" /> <!-- maxIdle -->
        <int value="10" /> <!-- minIdle -->
        <boolean value="true" /> <!-- testOnBorrow -->
        <boolean value="true" /> <!-- testOnReturn -->
        <long value="5000" /> <!-- timeBetweenEvctionRunsMillis -->
        <int value="5" /> <!-- numTestsPerEvictionRun -->
        <long value="5000" /> <!-- minEvictableIdleTimeMillis -->
        <boolean value="true" /> <!-- testWhileIdle -->
      </object>

      <object class="org.apache.commons.pool.impl.GenericKeyedObjectPoolFactory" null="true" />

      <string null="true" />

      <boolean value="false" />

      <boolean value="true" />

</object>


===================================================================

6. WAS 재구동 & 테스트

        //initial
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;

        try {

                //get Connnection
                conn = DriverManager.getConnection("jdbc:apache:commons:dbcp:/pool");
                conn.setAutoCommit(false);
                stmt = conn.createStatement();

                .................

        } catch(Exception ex) {
                conn.rollback();
                ex.printStackTrace();
                out.println(ex.toString());
        } finally {
                if ( rs != null ) try { rs.close(); } catch( Exception exf ){}
                if ( stmt != null ) try { stmt.close(); } catch( Exception exf ){}
                if ( conn != null ) try { conn.close(); } catch( Exception exf ){}
        }


===================================================================

7. Tip

 - 5번의 pool.jocl 파일을 여러개 생성하면, DB개정을 여러개 가져갈 수 있쥐요~

 - 5번의 maxWait 값이 작으면 에러가 발생할 수 있다.( 정확한 에럼 메세지가 기억 안남 ^^;;;)

===================================================================

Posted by 1010
98..Etc/Etc...2008. 7. 7. 17:27
반응형

브라우저에 붙여서 웹 개발시 도움이 될만한 툴이 다음처럼 몇가지 있습니다.

# Explorer용
1. IE Developer Toolbar
2. IE HTTP Analyzer

# Firefox용
3. Firebug
4. Web Developer Extension

Posted by 1010
02.Oracle/DataBase2008. 7. 7. 17:26
반응형

50만건이 넘는 데이타를 읽어서 insert 할 일이 생겼는데 보통의 방법으로 하니 톰켓이 계속 죽어 버리는 일이 생겼습니다.

자바 API를 보니 이러한 방법이 있더군요...


 

try {
            StringBuffer query = new StringBuffer();
            query.append("INSERT INTO ABT231 ");
            query.append("(customer_no, item_cd, occur_amt, reason_cd, register_ymd, register_no) ");
            query.append(" VALUES (?, ?, ?, '9', ?, ?) ");

            conn = getConnection();
            conn.setAutoCommit(false);

            pstmt = conn.prepareStatement(query.toString());
            Iterator iter = m_abt231InsertList.iterator();
            int count = 0;

            while( iter.hasNext() ) {
                m_abt231 = (Abt231) iter.next();
                pstmt.setInt(1, m_abt231.getCustomerNo());
                pstmt.setString(2, m_abt231.getItemCd());
                pstmt.setLong(3, m_abt231.getOccurAmt());
                pstmt.setString(4, s_magamCurrentTime);
                pstmt.setInt(5, Integer.parseInt(s_workCd));
                pstmt.addBatch();
                count++;
                if( (count % 10000) == 0){
                    System.out.println(count + "건 처리중");
                    pstmt.executeBatch();
                }
            }

           
pstmt.executeBatch();
            conn.commit();

}

Posted by 1010
02.Oracle/DataBase2008. 7. 7. 17:25
반응형
여기서는 full=y를 사용했을 경우만 생각해본다.
이는 DBA권한을 가진 사람이 모든 데이터베이스에 대해 백업을 실시할 때 사용한다.
full옵션을 사용할 수 있으려면 정확히 EXP_FULL_DATABASE 권한을 가져야한다.
export유틸리티를 사용하기 위해 catexp.sql이라는 유틸리티스크립트를 실행해야 하는데
이것은 catalog.sql이 실행되면서 부수적으로 실행되므로 그리 신경쓸 필요는 없다.

export는 논리적인 백업으로 완벽한 복구에 사용되기에는 무리이다.
많은(아주 많은 것 같다.) 사이트들이 백업수단으로 export를 사용하는 것 같다.
사용하기 쉬운 것과 짧은 시간에 할 수 있다는 것이 그 이유가 아닌가 생각된다.
개인적인 생각에는 export의 경우, 각 schema에 대한 백업수단(export시 owner옵션을 사용한 백업)으로서만
사용하는 것이 좋을것 같다.

full=y를 사용할 경우 inctype으로 complete, cumulative, incremental 3가지가 사용될 수 있다.
complete는 무조건 전체 데이터베이스를 백업.
cumulative는 complete이후 변경된 데이블에 대해서만 백업
incremental는 위 2가지 백업뒤 변경된 놈들에 대해 백업

cumulative는 incremental로 생성되는 파일수를 줄여주는 역활을 한다.
즉, 이전에 incremental백업을 2번한 상황에서 comulative백업을 하면 이전의 2개의 incremental백업은
cumulative백업으로 커버가 된다. 즉, 이전 2개의 incremental백업은 복구시 필요치 않고, cumulative백업
하나만 있으면 되는 것이다.

2주일간의 백업정책을 세운다면,
처음 complete백업을 받는다.
일별로 incremental백업을 받는다.
하지만, 수요일, 일요일은 incremental백업대신 cumulative백업을 한다.
2주가 되는 일요일에 complete백업을 한다.

복구의 순서는,
가장 최근의 complete백업한 것을 resotre한다.
가장 최근의 complete백업후에 발생한 cumulative백업들을 restore한다.
(cumulative백업이 없다면 incremental백업으로 대체)
위에서 행한 cumulative백업들중 가장 최근의 cumulative백업후의 incremental백업들을
가장 오래된 것부터 차례로 restore한다.

정리하면,
complete의 경우 주말에 한번 정도
incremental의 경우 날마다
cumulative의 경우 주중에 한번(수요일정도)

오라클이 complete백업후의 변동된 사항을 어떻게 알수 있을까?
당연히 내부적인 테이블에 이런 정보를 저장하고 있다.
언제 complete, cumulative백업들이 발생했는가등등.. 문서하단에 자세히 설명하겠다.

[kang@piruks kang]$ exp userid=system/xxxxxx full=y inctype=complete

Export: Release 8.1.6.1.0 - Production on Thu Nov 2 15:35:28 2000

(c) Copyright 1999 Oracle Corporation.  All rights reserved.


Connected to: Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production
Export done in UTF8 character set and KO16KSC5601 NCHAR character set

About to export the entire database ...
. exporting tablespace definitions
. exporting profiles
. exporting user definitions
. exporting roles
. exporting resource costs
. exporting rollback segment definitions
. exporting database links
. exporting sequence numbers
. exporting directory aliases
. exporting context namespaces
. exporting foreign function library names
. exporting object type definitions
. exporting system procedural objects and actions
. exporting pre-schema procedural objects and actions
. exporting cluster definitions
. about to export SYSTEM's tables via Conventional Path ...
. . exporting table                    DEF$_AQCALL          0 rows exported
. . exporting table                   DEF$_AQERROR          0 rows exported
. . exporting table                  DEF$_CALLDEST          0 rows exported
. . exporting table               DEF$_DEFAULTDEST          0 rows exported
. . exporting table               DEF$_DESTINATION          0 rows exported
. . exporting table                     DEF$_ERROR          0 rows exported
. . exporting table                       DEF$_LOB          0 rows exported
. . exporting table                    DEF$_ORIGIN          0 rows exported
. . exporting table                DEF$_PROPAGATOR          0 rows exported
. . exporting table       DEF$_PUSHED_TRANSACTIONS          0 rows exported
. . exporting table                  DEF$_TEMP$LOB          0 rows exported
. . exporting table                           HELP        816 rows exported
. . exporting table        SQLPLUS_PRODUCT_PROFILE          0 rows exported
. about to export OUTLN's tables via Conventional Path ...
. . exporting table                            OL$          0 rows exported
. . exporting table                       OL$HINTS          0 rows exported
. about to export DBSNMP's tables via Conventional Path ...
. about to export TRACESVR's tables via Conventional Path ...
. about to export KANG's tables via Conventional Path ...
. . exporting table                           TEST          1 rows exported
. exporting referential integrity constraints
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting triggers
. exporting snapshots
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting user history table
. exporting default and system auditing options
. exporting statistics
Export terminated successfully without warnings.

[kang@piruks kang]$ ls -l
total 155
-rw-rw-r--    1 kang     kang       155648 11월  2 15:37 expdat.dmp
drwxrwxr-x    4 kang     kang         1024 10월 27 13:02 public_html/
drwxrwxr-x    2 kang     kang         1024 10월 15 12:54 test/

complete로 백업후 바로 cumulative로 다시 실행해 봤다.
역시 변경사항이 없으니 .. 별 일은 하지 않는것 같다.
백업받을 파일을 지정하지 않으면 complete로 백업받은 파일을 덮어쓰니까
다른 곳으로 미리 옮겨놓는 것이 좋을 것 같다.

[kang@piruks kang]$ exp userid=system/xxxxxx full=y inctype=cumulative

Export: Release 8.1.6.1.0 - Production on Thu Nov 2 15:39:22 2000

(c) Copyright 1999 Oracle Corporation.  All rights reserved.


Connected to: Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production
Export done in UTF8 character set and KO16KSC5601 NCHAR character set

About to export the entire database ...
. exporting tablespace definitions
. exporting profiles
. exporting user definitions
. exporting roles
. exporting resource costs
. exporting rollback segment definitions
. exporting database links
. exporting sequence numbers
. exporting directory aliases
. exporting context namespaces
. exporting foreign function library names
. exporting object type definitions
. exporting system procedural objects and actions
. exporting pre-schema procedural objects and actions
. exporting cluster definitions
. about to export SYSTEM's tables via Conventional Path ...
. about to export OUTLN's tables via Conventional Path ...
. about to export DBSNMP's tables via Conventional Path ...
. about to export TRACESVR's tables via Conventional Path ...
. about to export KANG's tables via Conventional Path ...
. exporting referential integrity constraints
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting triggers
. exporting snapshots
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting user history table
. exporting default and system auditing options
. exporting information about dropped objects
. exporting statistics
Export terminated successfully without warnings.

파일의 크기가 줄었다.
[kang@piruks kang]$ ls -l                                              
total 27
-rw-rw-r--    1 kang     kang        24576 11월  2 15:42 expdat.dmp
drwxrwxr-x    4 kang     kang         1024 10월 27 13:02 public_html/
drwxrwxr-x    2 kang     kang         1024 10월 15 12:54 test/

역시 아무런 변경없이 incremental로 다시 실행해봤다.
생각한대로 별 일은 하지 않는다. 파일크기도 cumulative와 같았다.

[kang@piruks kang]$ exp userid=system/xxxxxx full=y inctype=incremental

Export: Release 8.1.6.1.0 - Production on Thu Nov 2 15:40:29 2000

(c) Copyright 1999 Oracle Corporation.  All rights reserved.


Connected to: Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production
Export done in UTF8 character set and KO16KSC5601 NCHAR character set

About to export the entire database ...
. exporting tablespace definitions
. exporting profiles
. exporting user definitions
. exporting roles
. exporting resource costs
. exporting rollback segment definitions
. exporting database links
. exporting sequence numbers
. exporting directory aliases
. exporting context namespaces
. exporting foreign function library names
. exporting object type definitions
. exporting system procedural objects and actions
. exporting pre-schema procedural objects and actions
. exporting cluster definitions
. about to export SYSTEM's tables via Conventional Path ...
. about to export OUTLN's tables via Conventional Path ...
. about to export DBSNMP's tables via Conventional Path ...
. about to export TRACESVR's tables via Conventional Path ...
. about to export KANG's tables via Conventional Path ...
. exporting referential integrity constraints
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting triggers
. exporting snapshots
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting user history table
. exporting default and system auditing options
. exporting information about dropped objects
. exporting statistics
Export terminated successfully without warnings.

[kang@piruks kang]$ ls -l                                               
total 27
-rw-rw-r--    1 kang     kang        24576 11월  2 15:43 expdat.dmp
drwxrwxr-x    4 kang     kang         1024 10월 27 13:02 public_html/
drwxrwxr-x    2 kang     kang         1024 10월 15 12:54 test/


음.. 데이터를 하나 넣어보고 다시 해보자
[kang@piruks kang]$ sqlplus kang/xxxxxx                             

SQL*Plus: Release 8.1.6.0.0 - Production on Thu Nov 2 15:46:34 2000

(c) Copyright 1999 Oracle Corporation.  All rights reserved.


Connected to:
Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production

SQL> insert into test values ('하하하', 29);

1 row created.

SQL> exit
Disconnected from Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production

incremental로 다시 백업
물론 변경사항이 있으니 뭔가 할 거다.
test테이블에 대해 2개의 row를 백업받았다.
export는 row단위로 백업하는 것이 아니기때문에 이는 test라는 테이블전체를 백업받은 것이다.
다시 한번 말하는데 export는 변경된
테이블에 대해 백업을 실시한다.
[kang@piruks kang]$ exp userid=system/xxxxxx full=y inctype=incremental

Export: Release 8.1.6.1.0 - Production on Thu Nov 2 15:48:11 2000

(c) Copyright 1999 Oracle Corporation.  All rights reserved.


Connected to: Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production
Export done in UTF8 character set and KO16KSC5601 NCHAR character set

About to export the entire database ...
. exporting tablespace definitions
. exporting profiles
. exporting user definitions
. exporting roles
. exporting resource costs
. exporting rollback segment definitions
. exporting database links
. exporting sequence numbers
. exporting directory aliases
. exporting context namespaces
. exporting foreign function library names
. exporting object type definitions
. exporting system procedural objects and actions
. exporting pre-schema procedural objects and actions
. exporting cluster definitions
. about to export SYSTEM's tables via Conventional Path ...
. about to export OUTLN's tables via Conventional Path ...
. about to export DBSNMP's tables via Conventional Path ...
. about to export TRACESVR's tables via Conventional Path ...
. about to export KANG's tables via Conventional Path ...
. . exporting table                           TEST          2 rows exported
. exporting referential integrity constraints
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting triggers
. exporting snapshots
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting user history table
. exporting default and system auditing options
. exporting information about dropped objects
. exporting statistics
Export terminated successfully without warnings.
[kang@piruks kang]$ ls -l
total 27
-rw-rw-r--    1 kang     kang        24576 11월  2 15:48 expdat.dmp
drwxrwxr-x    4 kang     kang         1024 10월 27 13:02 public_html/
drwxrwxr-x    2 kang     kang         1024 10월 15 12:54 test/

이번에는 좀더 데이터를 많이 집어넣어 보자
[kang@piruks kang]$ sqlplus kang/xxxxxx

SQL*Plus: Release 8.1.6.0.0 - Production on Thu Nov 2 15:49:16 2000

(c) Copyright 1999 Oracle Corporation.  All rights reserved.


Connected to:
Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production

SQL> insert into test values ('&a', 30);
Enter value for a: 슈퍼맨
old   1: insert into test values ('&a', 30)
new   1: insert into test values ('슈퍼?, 30)

1 row created.

SQL> /
Enter value for a: 배트맨
old   1: insert into test values ('&a', 30)
new   1: insert into test values ('배트?, 30)

1 row created.

SQL> /
Enter value for a: vicman
old   1: insert into test values ('&a', 30)
new   1: insert into test values ('vicman', 30)

1 row created.

SQL> quit
Disconnected from Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production
[kang@piruks kang]$ exp userid=system/xxxxxx full=y inctype=incremental

Export: Release 8.1.6.1.0 - Production on Thu Nov 2 15:50:24 2000

(c) Copyright 1999 Oracle Corporation.  All rights reserved.


Connected to: Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production
Export done in UTF8 character set and KO16KSC5601 NCHAR character set

About to export the entire database ...
. exporting tablespace definitions
. exporting profiles
. exporting user definitions
. exporting roles
. exporting resource costs
. exporting rollback segment definitions
. exporting database links
. exporting sequence numbers
. exporting directory aliases
. exporting context namespaces
. exporting foreign function library names
. exporting object type definitions
. exporting system procedural objects and actions
. exporting pre-schema procedural objects and actions
. exporting cluster definitions
. about to export SYSTEM's tables via Conventional Path ...
. about to export OUTLN's tables via Conventional Path ...
. about to export DBSNMP's tables via Conventional Path ...
. about to export TRACESVR's tables via Conventional Path ...
. about to export KANG's tables via Conventional Path ...
. . exporting table                           TEST          5 rows exported
. exporting referential integrity constraints
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting triggers
. exporting snapshots
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting user history table
. exporting default and system auditing options
. exporting information about dropped objects
. exporting statistics
Export terminated successfully without warnings.

입력한 데이터가 별로 되지 않아 백업파일의 크기에 영향이 없다. 쩝..
[kang@piruks kang]$ ls -l
total 28
-rw-r--r--    1 kang     kang            5 11월  2 15:51 HantermLog.GDPo9B
-rw-rw-r--    1 kang     kang        24576 11월  2 15:50 expdat.dmp
drwxrwxr-x    4 kang     kang         1024 10월 27 13:02 public_html/
drwxrwxr-x    2 kang     kang         1024 10월 15 12:54 test/

incremental과 cumulative의 차이점이라고 발견할 수 있는 것은 한가지다.
cumulative가 incremental로 백업받은 것을 다시 백업할 수 있지만,
incremental백업은 cumulative로 백업받은 것을 다시 백업할 수 없다는 것이다.
음.. 중요한 사실인가? 밑에 cumulative와 incremental의 예를 보면 알 수 있을 것이다.

[kang@piruks kang]$ exp userid=system/xxxxxx full=y inctype=cumulative

Export: Release 8.1.6.1.0 - Production on Thu Nov 2 15:51:48 2000

(c) Copyright 1999 Oracle Corporation.  All rights reserved.


Connected to: Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production
Export done in UTF8 character set and KO16KSC5601 NCHAR character set

About to export the entire database ...
. exporting tablespace definitions
. exporting profiles
. exporting user definitions
. exporting roles
. exporting resource costs
. exporting rollback segment definitions
. exporting database links
. exporting sequence numbers
. exporting directory aliases
. exporting context namespaces
. exporting foreign function library names
. exporting object type definitions
. exporting system procedural objects and actions
. exporting pre-schema procedural objects and actions
. exporting cluster definitions
. about to export SYSTEM's tables via Conventional Path ...
. about to export OUTLN's tables via Conventional Path ...
. about to export DBSNMP's tables via Conventional Path ...
. about to export TRACESVR's tables via Conventional Path ...
. about to export KANG's tables via Conventional Path ...
. . exporting table                           TEST          5 rows exported
. exporting referential integrity constraints
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting triggers
. exporting snapshots
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting user history table
. exporting default and system auditing options
. exporting information about dropped objects
. exporting statistics
Export terminated successfully without warnings.

cumulative백업후 데이터베이스에 아무런 변경없는 상태에서 incremental백업은 무의미하다.
즉 cumulative가 받은 백업데이터를 백업하지 못한다.

[kang@piruks kang]$ exp userid=system/xxxxxx full=y inctype=incremental

Export: Release 8.1.6.1.0 - Production on Thu Nov 2 15:52:05 2000

(c) Copyright 1999 Oracle Corporation.  All rights reserved.


Connected to: Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production
Export done in UTF8 character set and KO16KSC5601 NCHAR character set

About to export the entire database ...
. exporting tablespace definitions
. exporting profiles
. exporting user definitions
. exporting roles
. exporting resource costs
. exporting rollback segment definitions
. exporting database links
. exporting sequence numbers
. exporting directory aliases
. exporting context namespaces
. exporting foreign function library names
. exporting object type definitions
. exporting system procedural objects and actions
. exporting pre-schema procedural objects and actions
. exporting cluster definitions
. about to export SYSTEM's tables via Conventional Path ...
. about to export OUTLN's tables via Conventional Path ...
. about to export DBSNMP's tables via Conventional Path ...
. about to export TRACESVR's tables via Conventional Path ...
. about to export KANG's tables via Conventional Path ...
. exporting referential integrity constraints
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting triggers
. exporting snapshots
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting user history table
. exporting default and system auditing options
. exporting information about dropped objects
. exporting statistics
Export terminated successfully without warnings.




일반사용자는 데이터베이스 full백업이 불가능하다.
[kang@piruks kang]$ exp userid=kang/xxxxxx full=y inctype=incremental

Export: Release 8.1.6.1.0 - Production on Thu Nov 2 15:43:53 2000

(c) Copyright 1999 Oracle Corporation.  All rights reserved.


Connected to: Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production
EXP-00023: must be a DBA to do Full Database export
(2)U(sers), or (3)T(ables): (2)U >

EXP-00022: must be SYS or SYSTEM to do incremental export
EXP-00000: Export terminated unsuccessfully
[kang@piruks kang]$


full패러미터사용시 tables와 owner패러미터는 사용하지 못한다.
[kang@piruks kang]$ exp userid=system/xxxxxx full=y inctype=complete tables=kang.test

Export: Release 8.1.6.1.0 - Production on Thu Nov 2 15:45:55 2000

(c) Copyright 1999 Oracle Corporation.  All rights reserved.


Connected to: Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production
EXP-00026: conflicting modes specified
EXP-00000: Export terminated unsuccessfully
[kang@piruks kang]$


incexp, incfil, incvid
sys계정에 보면, incexp, incfil, incvid테이블이 있다.
보통의 owner, table백업으로는 이 테이블들이 채워지지 않는다.
cumulative, incremental을 해야 이 놈들의  테이블이 채워진다.
백업을 하면 백업기록을 남겨야 incremental backup을 할 수 있는데 이 놈들이다.

incexp: export된 스키마들의 정보를 가짐(보통 무지하게 row가 많다)
incfil: incremental backup이 된 export파일들
incvid: 다음 export id를 가짐(즉, 지금 한게 id가 1이라면 다음은 2가 된다.)

exp userid=system/xxxx file=fullexp.dmp full=y inctype=complete
exp userid=system/xxxx file=cumexp.dmp full=y inctype=cumulative
exp userid=sys/xxxx file=incexp.dmp full=y inctype=incremental

이렇게 2번을 하고, DB 에서 조회

SQL> select * from incfil;

     EXPID EXPTYPE  EXPFILE                        EXPDATE   EXPUSER
---------- -------- ------------------------------ --------- ------------------------------
         1 X        fullexp.dmp                    12-JAN-01 SYSTEM
         2 C        cumexp.dmp                     12-JAN-01 SYSTEM
         3 I        incexp.dmp                     12-JAN-01 SYS

SQL> select * from incvid;

     EXPID
----------
         3


SQL> select * from incexp where rownum<5;

    OWNER# NAME                      TYPE# CTIME     ITIME          EXPID
---------- -------------------- ---------- --------- --------- ----------
         5 DEF$_AQCALL                   2 12-JAN-01 12-JAN-01          1
         5 DEF$_AQERROR                  2 12-JAN-01 12-JAN-01          1
         5 DEF$_CALLDEST                 2 12-JAN-01 12-JAN-01          1
         5 DEF$_DEFAULTDEST              2 12-JAN-01 12-JAN-01          1



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

[엑스포트(Export)]

 

Export 유틸리티의 명령행 모드를 사용하여 데이터베이스 데이터를 운영 체제 파일로 복사할 수 있습니다. 이 파일은 Import 유틸리티에서만 읽을 수 있습니다.

예제

행을 포함하여 scott의 스키마에 속한 emp 및 dept 테이블을 포함하는 expincr1.dmp 엑스포트 파일을 생성합니다.

$ exp scott/tiger tables=(emp,dept) rows=y file=expincr1.dmp

행을 포함하여 scott의 스키마에 속한 모든 객체를 포함하도록 expdat.dmp라는 빠른 엑스포트 파일을 생성합니다.

$ exp system/manager owner=SCOTT DIRECT=Y

ts_emp 테이블스페이스에 속한 모든 객체의 정의를 포함하는 expdat.dmp 엑스포트 파일을 생성하고 ts_emp.log 로그 파일을 생성합니다.

$ exp system/manager TRANSPORT_TABLESPACE=y TABLESPACES=(ts_emp) LOG=ts_emp.log

마지막 누적 또는 완전 엑스포트 이후 데이터베이스에서 수정된 모든 정의 및 데이터를 포함하는 expcum1.dmp 엑스포트 파일을 생성합니다.

$ exp system/manager FULL=y INCTYPE=cumulative FILE=expcum1.dmp

참고: 명령행 모드 옵션은 대화식 모드 옵션과 유사합니다.

 

엑스포트 매개변수

매개변수

설명

USERID

엑스포트할 스키마 객체의 사용자 이름/암호

FILE

출력 파일 이름

ROWS

엑스포트 파일에 테이블 행을 포함시킬 것인지 여부: (Y)es/(N)o

FULL

전체 데이터베이스를 엑스포트할 것인지 여부: (Y)es/(N)o

OWNER

엑스포트할 사용자: 사용자 이름

TABLES

엑스포트할 테이블: 테이블 목록

INDEXES

인덱스를 엑스포트할 것인지 여부: (Y)es/(N)o

DIRECT

직접 모드 엑스포트 지정 여부: (Y)es/(N)o

INCTYPE

엑스포트 레벨 유형

PARFILE

매개변수가 지정된 파일 이름

HELP

대화식 모드에서 엑스포트 매개변수 표시(Y)

LOG

정보 및 오류 메시지용 파일 이름

CONSISTENT

엑스포트 중에 데이터가 갱신될 경우 데이터베이스의 읽기 일관성 뷰를 제공할 것인지 여부: (Y)es/(N)o

BUFFER

데이터 버퍼 크기(바이트): (정수)

TRANSPORT_TABLESPACE

이동 가능한 테이블스페이스 메타 데이터의 엑스포트 설정(릴리스 8.1 전용)

TABLESPACES

이동할 테이블스페이스(릴리스 8.1 전용)

POINT_IN_TIME_RECOVER

Export 유틸리티가 Oracle 데이터베이스에 있는 하나 이상의 테이블스페이스를 엑스포트할지 여부 표시(릴리스 8.0 전용)

RECOVERY_TABLESPACES

포인트 인 타임 복구를 사용하여 복구할 테이블스페이스 지정(릴리스 8.0 전용)
Oracle Server Readme, Release 8.0.4 참조

COMPRESS

하나의 확장 영역에 모든 데이터를 포함시킬지 여부 지정: (Y)es/(N)o

참고: 위에 나열한 매개변수는 모든 Export 유틸리티 매개변수의 전체 목록이 아니며 DBA가 복원을 위해 자주 사용하는 매개변수입니다

 

 

[임포트(import)]

 

expincr1.dmp 엑스포트 파일을 사용하여 행을 포함해 emp 및 dept 테이블을 scott 스키마로 임포트합니다.

$ imp scott/tiger tables=(emp,dept) rows=y file=expincr1.dmp

expincr1.dmp 엑스포트 파일을 사용하여 행을 포함해 Scott 스키마에 속한 모든 객체를 임포트합니다.

$ imp system/manager FROMUSER=scott file=expincr1.dmp

expdat.dmp 엑스포트 파일을 사용하여 ts_emp 테이블스페이스에 속한 모든 객체의 정의를 임포트합니다.

$ imp system/manager TRANSPORT_TABLESPACE=y TABLESPACES=ts_emp

참고: 명령행 모드 옵션은 대화식 모드 옵션과 유사합니다.

 

임포트 매개변수

매개변수

설명

USERID

임포트할 스키마 객체의 사용자 이름/암호

FILE

입력 파일의 이름. 유효한 Export 유틸리티 파일이어야 합니다.

ROWS

임포트 파일에 테이블 행을 포함시킬지 여부

IGNORE

해당 객체가 존재할 경우 생성 오류 무시

FULL

전체 파일 임포트

TABLES

임포트할 테이블

INDEXES

인덱스를 임포트할 것인지 여부

INCTYPE

증분 임포트 유형 지정. SYSTEM 및 RESTORE 옵션이 있습니다.

PARFILE

매개변수 사양 파일

HELP

대화식 모드에서 엑스포트 매개변수 표시

LOG

정보 및 오류 메시지용 파일

DESTROY

데이터베이스를 구성하는 기존 데이터 파일을 재사용해야 할지 여부 지정

FROMUSER

임포트할 객체를 포함하는 스키마 목록

TOUSER

임포트할 스키마를 소유한 사용자 이름 목록 지정

INDEXFILE

인덱스 생성 명령을 받을 파일 지정

TRANSPORT_TABLESPACE

엑스포트 파일에 있는 이동 가능한 테이블스페이스 메타 데이터를 Import 유틸리티가 임포트하도록 명령

TABLESPACES

데이터베이스로 이동할 테이블스페이스 목록

DATAFILES

데이터베이스로 이동할 데이터 파일 목록

TTS_OWNERS

이동 가능한 테이블스페이스 집합에 있는 데이터를 소유한 사용자 목록

POINT_IN_TIME_RECOVER

Import 유틸리티가 나머지 데이터베이스에 영향을 주지 않고 Oracle 데이터베이스에 있는 하나 이상의 테이블스페이스를 이전 시점으로 복구할지 여부 표시(릴리스 8.0 전용)

참고: 위에 나열한 매개변수는 모든 Import 유틸리티 매개변수의 전체 목록이 아니며 DBA가 복원 작업을 위해 자주 사용하는 매개변수입니다.

Posted by 1010
반응형

imp system/java fromuser='systme' touser='smbi' file='smbi_20080501.dmp' tables='sbedfp'

exp 한후 imp 시...

fromuser -> touser ... 맞게..

Posted by 1010
01.JAVA/Java2008. 7. 7. 17:21
반응형
★ MultipartRequest를 이용하여 업로드구현하기

Last Modified 2002/05/26
Written by hsboy
ReadCount 2250


* 강좌를 시작하기전에....

- 기존의 jspSmartUpload를 대체해 가고 있는 MultipartRequest에 대한 간단한 사용법에 대해 강의 합니다.
JSP만을 사용하는 강좌이며 Beans, Servlet은 다루지 않습니다.

- MultipartRequest는 COS 패키지에 포함되어 있는 파일 업로드 컴포넌트 입니다.

- COS 에서는 한글등(non-Latin-1)의 언어를 지원하지 않았었습니다. 그러한 이유로 이아스(이창신)님 께서 배포한 COSI(COS International) 를 주로 사용 하였으나, 이아스님의 노력에 힘입어 2002년 5월 9일 자 COS에서는 한글을 포함한 non-Latin-1 계열의 언어를 지원하게 되었습니다. 근 2년간의 국제화를 위한 투쟁이 비로서 결실을 맺는 순간이었습니다.
이에 따라 본 강좌의 내용도 COS 맞추어 약간의 수정을 했습니다.

COS 공식 사이트 : http://www.servlets.com/cos/index.html


* MultipartRequest는....

필자는 기존에 jspSmartUpload를 주로 사용하여 업로드를 구현했었다. 하지만 jspSmartUpload는 로직자체에 상당한 문제점(업로드된 파일을 메모리에 올리고 작업하여 그로인해 파생되는 문제점들)이 있음이 밝혀 졌고, 그로인해 jspSmartUpload의 사용은 급속히 줄어 들었다.

사실 jspSmartUpload에서는 편리한 많은 메소드를 지원해주고 있어 MultipartRequest를 사용하는것 보다 훨씬 쉽게 원하는 기능을 구현 할수 있는 것이 사실이다. 하지만 jspSmartUpload는 문제점이 발견 되었으므로 가능한사용을 자제하는 것이 좋겠다.

MultipartRequest는 아주 간단한 메소드를 몇개 지원한다. 하지만 이 메소드들 만으로도 왠만한 기능은 전부 구현이 가능하니 실망하지 말자. getFile() 메소드를 이용하면 java.io.File 객체를 얻어 낼수 있으니 이를 이용하면 될것이다.


* 설치하기

MultipartRequest는 oreilly에서 배포하며, http://www.servlets.com/cos/index.html에서 다운로드 받아도 되고, 필자의 홈페이지(http://aboutjsp.com)의 자료실에도 업로드를 해놓았으니 다운받아 사용해 보기 바란다.

설치 하는 방법은 다운로드 받아서 압축을 푼뒤, classes 디렉토리 아래를 톰캣의 classes 디렉토리에 통째로 복사한다. (예.ROOT/WEB-INF/classes) 혹은 cos.jar를 lib에 복사해도 된다.

COS 패키지기에는 MultipartRequest 말고도 유용한 많은 클래스들이 많이 존재하므로, 여기의 API문서를 참고하여 사용하기 바란다


* 업로드 구현

간단한 예제를 통해서 알아 보도록 하자.

wirte.htm
<html> <body> <form action="up.jsp" enctype="multipart/form-data" method="post"> 이름 : <input type="text" name="userName"> <br /> 파일 : <input type="file" name="upfile"> <input type="submit" value="Upload"> </form> <script type="text/javascript">(function($) { $(document).ready(function() { lightbox.options.fadeDuration = 200; lightbox.options.resizeDuration = 200; lightbox.options.wrapAround = false; lightbox.options.albumLabel = "%1 / %2"; }) })(tjQuery);</script> <div style="margin:0; padding:0; border:none; background:none; float:none; clear:none; z-index:0"></div> <script type="text/javascript" src="https://tistory1.daumcdn.net/tistory_admin/userblog/tistory-e11b6cd63d67e948b9dd33a1d0a60492dd6a0cbf/static/script/common.js"></script> <script type="text/javascript">window.roosevelt_params_queue = window.roosevelt_params_queue || [{channel_id: 'dk', channel_label: '{tistory}'}]</script> <script type="text/javascript" src="//t1.daumcdn.net/midas/rt/dk_bt/roosevelt_dk_bt.js" async="async"></script> <script type="text/javascript" src="https://tistory1.daumcdn.net/tistory_admin/userblog/tistory-e11b6cd63d67e948b9dd33a1d0a60492dd6a0cbf/static/script/menubar.min.js"></script> <script>window.tiara = {"svcDomain":"user.tistory.com","section":"홈","trackPage":"홈_보기","page":"홈","key":"218144","customProps":{"userId":"0","blogId":"218144","entryId":"null","role":"guest","trackPage":"홈_보기","filterTarget":false},"entry":null,"kakaoAppKey":"3e6ddd834b023f24221217e370daed18","appUserId":"null"}</script> <script type="module" src="https://t1.daumcdn.net/tistory_admin/frontend/tiara/v1.0.0/index.js"></script> <script src="https://t1.daumcdn.net/tistory_admin/frontend/tiara/v1.0.0/polyfills-legacy.min.js" nomodule="true" defer="true"></script> <script src="https://t1.daumcdn.net/tistory_admin/frontend/tiara/v1.0.0/index-legacy.js" nomodule="true" defer="true"></script> </body> </html>

up.jsp
<%@ page contentType="text/html;charset=euc-kr" 
%><%@ page import="com.oreilly.servlet.MultipartRequest,
                   com.oreilly.servlet.multipart.DefaultFileRenamePolicy,
                   java.util.*" 
%><%
 String savePath="/usr/local/tomcat/webapps/ROOT/test/upload"; // 저장할 디렉토리 (절대경로)

 int sizeLimit = 5 * 1024 * 1024 ; // 5메가까지 제한 넘어서면 예외발생

 try{

	MultipartRequest multi=new MultipartRequest(request, savePath, sizeLimit, new DefaultFileRenamePolicy());
 	Enumeration formNames=multi.getFileNames();  // 폼의 이름 반환
	String formName=(String)formNames.nextElement(); // 자료가 많을 경우엔 while 문을 사용
	String fileName=multi.getFilesystemName(formName); // 파일의 이름 얻기

	if(fileName == null) {   // 파일이 업로드 되지 않았을때
		out.print("파일 업로드 되지 않았음");
	} else {  // 파일이 업로드 되었을때
		fileName=new String(fileName.getBytes("8859_1"),"euc-kr"); // 한글인코딩 - 브라우져에 출력
		out.print("User Name : " + multi.getParameter("userName") + "<BR>");
		out.print("Form Name : " + formName + "<BR>");
		out.print("File Name  : " + fileName);
	} // end if

 } catch(Exception e) {
	out.print("예외 상황 발생..! ");
 } 
%>
				

위의 예제 소스를 보면 대부분이 이해가 잘 갈것이라 생각되지만.. 하나씩 살펴 보도록 하겠다. 우선 write.htm 에서는 폼에서 method="post" 형식으로 해야 하며 ecntype="multipart/form-data" 를 꼭 붙여 주어야 한다.

다음으로 up.jsp를 하나 하나 살펴 보자. MultipartRequest 클래스를 import 하고, java.util.* 는Enumeration 객체를 사용하기 위해서 import 한다..

savePath 는 저장될 실제 디렉토리(시스템상의 절대 경로)를 적으면 된다. sizeLimit 에서는 제한 용량을 셋팅하는데, 위와같은방법으로 메가바이트 단위로 지정할 수 있다.

그 다음줄에서는 MultipartRequest 객체가 생성됨과 동시에 업로드가 이루어져 지정한 디렉토리에 저장된다. 이때 MultipartRequest의 여러 생성자들중 하나를 이용하면 되는데, 기존에는 새성자로 한글 "euc-kr"을 줬어야 했는데, 어쩐일인지 이제는 주지 않아아 한글 이름의 파일이 잘 저장되느는 것을 볼수 있다. 또한 가장 오른쪽의 'new DefaultFileRenamePolicy' 는 는 파일 이름 중복처리에 관한 것으로 넣을수도 있고, 뺄수도 있다. 필요하지 않다고 생각된다면 빼버리도록 하자.

그아래에 if 문을 보면, 파일이 업로드 되었을때와 업로드 되지 않았을때의 처리를 나누어서 할수 있도록 하고 있다.

if 문 위의 3라인은 파일의 이름을 얻기위한 로직으로 Enumeration 객체로 받은 폼의 이름을 이용하고 있다. 만약 폼이 여러개가 있을 경우엔 적절한 자료형을 이용하여 폼의 이름을 통해서 파일의 이름들을 얻어 낼수 있을 것이다. 만약 파일 업로드를 Beans로 구현할 경우엔 반드시 이러한 로직을(Enumeration 객체를 이용한 loop구문)사용해야 할 것이다.

사실 위의 예제에서는 굳이 Enumerration 객체를 가지고 구현할 필요는 없지만, 해당 메소드의 사용법을 보여주기 위해서 사용하였다. 이러한 방법을 사용하지 않을 경우에는 if 위에 3라인을 삭제하고 아래의 내용을 추가 하면다.

String fileName=multi.getFilesystemName("upfile");


* FileRenamePolicy 에 관해서...

이번 버젼의 MultipartRequest 에서 부터는 파일 중복처리 인터페이스가 추가 되었고, 위의 예제 소스는 그러한 내용이 반영되어있다. DefaultFileRenamePolicy는 FileRenamePolicy Interface 를 구현한 것으로, 중복된 파일 이름뒤에 숫자를 붙여 주고 있다. ( abcd.zip , abcd1.zip, abcd2.zip, abcd3.zip ....... )

DefaultFileRenamePolicy Class를 바탕으로 새로운 RenamePolicy class 를 만들면 자신이 원하는 FileRenamePolicy 를 적용할수 있다.

또한 getFilesystemName()메소드를 이용하여 변경된 파일 이름을 얻을수 있고, getOriginalFileName()메소드는 변경되기 이전의 파일이름을 넘겨준다.


* multi.getParameter()

write.htm 에서 서정한바와 같이 enctype="multipart/form-data" 로 지정하면, request.getParameter()로는 아무러 값도 받아 올수가 없게된다. 그러한 이유로 대부분의 파일업로드 컴포넌트에서는 getParameter() 메소드를 지원하는데, MultipartRequest에서도 이러한 메소드를 지원한다. 지원하는 메소드는 아래와 같으며, 사용법은 request.getParameter() 등과 동일하다.

String getParameter(String name)
Enumeration getParameterNames()
String[] getParameterValues(String name)


* 한글관련 문제 처리법

MultipartRequest multi=new MultipartRequest(request, savePath, sizeLimit, new DefaultFileRenamePolicy());

위를 아래와 같이 수정한다.

MultipartRequest multi=new MultipartRequest(request, savePath, sizeLimit, "euc-kr", new DefaultFileRenamePolicy());

"euc-kr" 부분엔 "ksc5601", "ms949" 등 자신의 환경에 알맞는 캐릭터셋을 넣어 주면 된다.

각 메소드들에 대한 자세한 사용법은 아래의 API문서를 참고 하기 바란다.

http://aboutjsp.com/docs/cos/



* 관련사이트
http://www.servlets.com/cos/
   COS 공식 사이트

저자 : 이선재(hsboy)
http://www.aboutjsp.com
다른곳에 올리실 때는 반드시 출처를 명시해 주시기 바라며 되도록 이면 링크를 걸어 주시기 바랍니다.

Posted by 1010