2013년 8월 30일 금요일

android - backward compatibility

0. Support library

The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs. Each Support Library is backward-compatible to a specific Android API level. This design means that your applications can use the libraries' features and still be compatible with devices running Android 1.6 (API level 4) and up. 
Android의 Design Principles은 http://developer.android.com/design/ 에 잘 나와 있는데, 이러한 디자인 철학은 Ice Cream Sandwich - Android 4.0 부터 적용이 되기 때문에 app을 기획하고 개발할 때 하위 호환성(backward compatibility)이 고민된다. 
다행히 support library를 통해서 상위 버전의 api를 사용할 수 있게 해준다.

1. Adding Support Libraries

Some Support Libraries contain resources beyond compiled code classes, such as images or XML files. For example, the v7 appcompat and v7 gridlayout libraries include resources. 
설정하는 건 http://developer.android.com/tools/support-library/setup.html 에 잘 나와 있다. 
위 내용 처럼 resource를 포함하는 library도 있는데, 이 경우 문서에 빠진 내용이 있어 삽질을 좀 했다.

 기본적으로 android-support-v7-appcompat라는 library project를 생성한 후 나의 project의 build-path에 추가하는 내용인데 아래 중 1번과 2번 사이에 Android property를 선택하라는 내용이 빠져있다 ㅠㅠ Java Build Path에서 해매질 마시길 ..


 * eclipse에서 library project가 현재 project와 다른 workspace에 있으면 참조가 안된다. 주의!!!!!!

2013년 8월 20일 화요일

oracle - drop user (schema)

0. drop oracle schema

schema export/import를 위해 schema를 삭제하려면?
SQL> drop user schema_name cascade;

 ORA-01940: cannot drop a user that is currently connected 발생시?
SQL> select sid, serial#, username, status from v$session where schemaname='schema_name'
SQL> alter system kill session 'sid, serial#' immediate;
1. create user
SQL> create user schema_name identified by passwd;
        SQL> grant dba to schema_name;

2013년 8월 16일 금요일

oracle - export, import (export data pump)

0. overview

  • database를 export/import 하는 방법이다. 이건 backup/restore랑 다르다. 예를 들어 postgreSQL에서는 backup/restore를 통해서 database migration이 가능한데, oracle은 export/import 해줘야 한다.
  • 과거에는 exp/imp 를 사용했는데, 이제는 expdp/impdp(oracle data pump)를 사용해 준다.
Oracle Data Pump is a newer, faster and more flexible alternative to the "exp" and "imp" utilities used in previous Oracle versions. In addition to basic import and export functionality data pump provides a PL/SQL API and support for external tables.
  • oracle documentation 을 좀 살펴보자. 사실 export/import는 간단한데 중간 중간에 여러 걸림돌이 있어서 찾아가면서 하는데 많이 힘들었다.
  • expdp/impdp 에 관한 매뉴얼도 역시 찾기 힘들었는데, 해당 메뉴얼은 document home > Information integration > Additional features > Utilites 문서에 나와 있다. 영어가 익숙하지 않아서 그런지 상상도 못한 곳에 문서가 있었다 -_-;

1. create user & grant DBA role

  • 처음 oracle을 설치한 환경이다. 설치 후 user를 생성해 준다.
sqlplus / as sysdba
SQL> create user username identified by password;
  •  권한을 준다. 권한에 대한 내용은 oracle documentation의 security 파트에 잘 나와 있다. 간편하게 모든 system 권한을 준다.
SQL> grant dba to username; 
  • DBA role 참고 
Provides all system privileges that were created with the ADMIN option.
This role is provided for compatibility with previous releases of Oracle Database. You can determine the privileges encompassed by this role 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 this role. This role may not be created automatically by future releases of Oracle Database.

2. DATA_PUMP_DIR

  • data pump를 사용할 때 oracle에서 사용하는 dir를 확인한다.
select * from dba_directories;
  • dump 파일의 위치는 위 조회 명령을 사용하면 나온다. directory_name이 data_pump_dir로 되어 있다.  

3. export

  • 간단하다. 당연히 관련 privilege 체크는 먼저 해줘야 한다.
expdp file=xxx.dmp log=xxx.log
  • 이 정도만 해주면 된다. option으로 table space, schema 등 어떤 레벨로 할지를 정할 수 있는데, 디폴트는 schema다.
  • data_pump_dir에 dmp 파일을 확인한다. 

4. import 

  • dmp 파일을 data_pump_dir에 copy 한다.
 impdp file=xxx.dmp

5. oracle documentation

  • http://www.oracle.com/pls/db112/homepage
  • 왼쪽 메뉴를 잘 봐야 한다. 현재 페이지는 getting started 페이지이고 여기 있는 문서들은 개요가 대부분이다. 예를 들어 dba essentials 에 있는 내용은 enterprise manager를 이용한 GUI 사용법들이다. 
  • sql 명령을 알고 싶다. 그러면 supporting documentation의 sql language reference를 본다.
  • 사실 predefined role, privilege 등을 보고 싶었는데 이 페이지의 문서에는 나와 있지 않다. 그럴때 왼쪽 메뉴의 database administration 하위의 security 페이지로 이동하여 문서를 찾는다. 
  • 아오!!

6. issue

  • 기존 database에 해당 동일한 schema가 있는 경우는 drop user 후 impdp 한다. 이때 version이 다른 경우 error가 발생할 수 있다.
  • 테스트 환경에서 발생한 문제로 11.2.0.1.0 --> 11.2.0.2.0 으로 impdp 할 때 timezone file이 달라 impdp가 안되었다. 이런 경우 zoneinfo 폴더의 timezlrg_xx.dat, timezone_xx.dat를 복사해서 넣어주면 해결된다. 버전은 아래와 같이 확인 가능하다.
select * from database_properties
  • 이러한 정보는 logfile=xxx.log 옵션을 주면 힌트를 얻을 수 있다.