APPLICATION/DNS2009. 9. 17. 15:35
반응형
네임서버를 설정하고 난 후에는 아래의 명령어로 설정사항을 검사할 수 있습니다.

named-checkconf 명령과 named-checkzone 명령어에 대한 사용법을 알아보겠습니다.

=================================================================================
named-checkconf - /etc/named.conf 파일을 검사하는 명령

-사용법
named-checkconf [named 설정파일 경로]

[root@server21010910234 root]# named-checkconf /etc/named.conf
[root@server21010910234 root]#

엔터를 쳤을때 위와 같이 아무런 반응없이 프롬프트가 떨어지면 named.conf 파일에 이상이 없는 것 입니다.

=================================================================================
named-checkzone - /var/named 디렉토리 하위에 설정한 zone 파일을 검사하는 명령

-사용법
named-checkzone [zone 네임] [zone 파일 경로]

------------------------------
zone "yahoo.com" IN {
       type master;
       file "yahoo.zone";
       allow-update { none; };
};
------------------------------

/etc/named.conf 파일에 위와 같이 zone 설정이 되어 있을때, 아래와 같은 방법으로 검사를 할 수 있습니다.

[root@server21010910234 root]# named-checkzone yahoo.com /var/named/yahoo.zone
zone localhost/IN: loaded serial 42
OK

반응형

'APPLICATION > DNS' 카테고리의 다른 글

DNS 서버 정보  (0) 2011.05.16
[펌] DNS 설정 및 BIND 소스 설치  (0) 2004.06.02
[펌] DNS 셋팅  (0) 2004.06.02
Posted by [PineTree]
ORACLE/ADMIN2009. 9. 15. 14:13
반응형
------------------------------------------------------------------------
ㅁ초기 size는 400k 공간, 필요시 다음번 400kb 증가하고 그 다음에는
size가 자동으로 증가하여 최대 10m 까지 사용할 수 있는 데이블스페이스 생성
------------------------------------------------------------------------
create tablespace tbs_02
datafile 'tbs_02.dat' size 400k
Autoextend on next 400k maxsize 10m;

select tablespace_name, file_name , bytes, blocks, status, autoextensible
from dba_data_files
where tablespace_name='TBS_02';

------------------------------------------------------------------------
ㅁ 전체 size 는 10mb 이고 공간이 더 필요할 경우 모든 extent 는 128kb로 증가
------------------------------------------------------------------------
create tablespace tbs_03
datafile 'c:\oradata\tbs_03.dbf' size 10m
extent management local
uniform size 128k;

------------------------------------------------------------------------
ㅁ 자동으로 segment 공간을 관리해주는 테이블 스페이스 생성 ==> 사용권장
------------------------------------------------------------------------
CREATE TABLESPACE auto_seg_ts
DATAFILE 'C:\ORADATA\auto_seg_ts.dbf' SIZE 1M
EXTENT MANAGEMENT LOCAL ----------> coalesce 작업필요없다.
SEGMENT SPACE MANAGEMENT AUTO ; ----------> latch 획득 필요 없다.

------------------------------------------------------------------------
ㅁ OMF 테이블 스페이스 생성
------------------------------------------------------------------------
select value from v$parameter where name='db_create_file_dest';
===> Data file 이 생성되는 목적지

alter system set db_create_file_dest='c:\oradata' scope=spfile;
===> Data file 이 생성되어지는 목적지 변경

SQL> shutdown immediate
SQL> startup

SQL> create tablespace omf_ts1;
===>'db_create_file_dest' 에 설정한 경로에 size가 무제한 자동으로 증가하는
100MB의 Data File이 랜덤한 이름으로 생성되어짐.

SQL> select file_name, tablespace_name, bytes, autoextensible
from dba_data_files
where tablespace_name='OMF_TS1';

SQL> create tablespace omf_ts2 datafile autoextend off; (100m차면 끝.. 자동증가 없음)
SQL> drop tablespace omf_ts1 including contents and datafiles;
====> 테이블스페이스 와 포함된 object그리고 os상 파일까지 모두 삭제


=================================
테이블스페이스 공간조회 스크립트
=================================

-------------------------------------------------------------------
accept v_tbsname prompt '테이블스페이스명: '
set verify off

select A.totbytes, A.totblocks, B.freebytes, B.freeblocks,
A.totbytes - B.freebytes "Usedbytes",
A.totblocks - B.freeblocks "Usedblocks"
from
(select tablespace_name,
sum(bytes) totbytes, sum(blocks) totblocks
from dba_data_files
where tablespace_name=upper('&v_tbsname')
group by tablespace_name
) A,
(select tablespace_name,
sum(bytes) freebytes, sum(blocks) freeblocks
from dba_free_space
where tablespace_name=upper('&v_tbsname')
group by tablespace_name
) B
where A.tablespace_name = B.tablespace_name
/

set verify on

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


=====================================
Tablespace 에 Datafile 추가
=====================================

=== 테이블 스페이스 생성 ===
SQL> create tablespace test1
datafile 'C:\oracle\oradata\ddba120\test1.dbf' size 1m
extent management local
segment space management auto;


=== 테이블 스페이스 남은 공간 보기 ===
select * from dba_free_space
where tablespace_name = 'TEST1';

==== 어느 블럭에 테이블이 쓰이나? ====

SELECT segment_name , extent_id, block_id, bytes, blocks
from dba_extents
where owner='SCOTT'
AND segment_name in ('EMP2','EMP3','EMP4','EMP5','EMP6','EMP7','EMP8');

[테이블스페이스 공간이 없을때 할 수 있는 작업]---------------------

[1방법] 데이타 파일을 추가 (권장)
alter tablespace test1
add datafile 'C:\oracle\oradata\ddba120\test11.dbf' size 1M;

[2방법] 용량을 늘린다.
alter database datafile
'C:\oracle\oradata\ddba120\test11.dbf' resize 2m;
--------------------------------------------------------------------------

===== 현재 segments를 사용중인 tablespace 검색해보자 =====

SELECT distinct tablespace_name from dba_segments;

--> 방금 생성한 test1 테이블 스페이스는 없다
--> 왜? 테이블이나 인덱스 같은 segments를 생성하지 않아서


select * from dba_tablespaces;

--> 테이블 스페이스가 모두 보여진다.

--------------------------------------------------------------
그럼~ 테이블 스페이스중에 object가 한개도 없는 것을 찾으려면
--------------------------------------------------------------

select tablespace_name
from dba_tablespaces
minus ================> 차집합
select distinct tablespace_name
from dba_segments;


=================================
Tablespace의 Online/Offline 설정
=================================


SQL> SELECT tablespace_name, status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE ---> 읽고 쓰기 가능 DML가능!
UNDOTBS1 ONLINE


==== 해당 테이블이 저장되는 테이블 스페이스 ====

SQL> select tablespace_name from dba_tables
where table_name ='DEPT' AND OWNER='SCOTT';

TABLESPACE_NAME
------------------------------
SYSTEM


===== 테이블스페이스 offline만들기 ======
SQL> create table scott.dept2
tablespace users
as
select * from scott.dept;

SQL> alter tablespace users offline;

SQL> select tablespace_name, status from dba_tablespaces; --> 상태조회
SQL> select * from scott.dept;
==> 실행 가능

SQL> select * from scott.dept2;
==> 실행 거부 왜? offline이니까


===== 테이블스페이스 read only 만들기 ======
SQL> alter tablespace users online;
SQL> alter tablespace users read only;
==> select만 되어진다.


===== 테이블스페이스 read write만들기 ======
SQL> alter tablespace users read write;
==> 다시 online으로 복귀

---> 해당 유저의 기본테이블 스페이스 보기

select default_tablespace
from dba_users
where username = 'SCOTT';

---> 기본 테이블스페이스 변경

alter user scott
default tablespace system;
(변경되어질 테이블스페이스)

=========================
데이타 파일 이동
=========================

Users Tablespace의 C:\oracle\oradata\ddba120\users01.dbf를
D:\로 이동시키고자 한다.


SQL> create table scott.kh
(name varchar2(20));
SQL> insert into scott.kh values('송파교육원');
SQL> alter tablespace users offline; --> offline으로 우선 만든다

SQL> alter tablespace users
rename datafile 'C:\oracle\oradata\ddba120\USERS01.DBF'
to 'D:\ORADATA2\USERS01.DBF';
---> 변경할 위치를 적어주죠~~!!!

SQL> alter tablespace users online;
SQL> select tablespace_name, status from dba_tablespaces;
--> online/offline 상태조회

SQL> select tablespace_name, file_name, status from dba_data_files
where tablespace_name='USERS' ;
--> 데이타파일 상태조회

------------------
USERS
D:\ORADATA2\USERS01.DBF
AVAILABLE


---------------------------------------------------
---- 다시 원상복귀 그러나 다른 밥법!!! 기대하시랏!!!----
---------------------------------------------------

SQL> SHUTDOWN IMMEDIATE
'D:\ORADATA2\USERS01.DBF' 있는 것을 잘라내서
'C:\oracle\oradata\ddba120\USERS01.DBF' 로 붙여넣기

SQL> startup mount

SQL> alter database
rename file 'D:\ORADATA2\USERS01.DBF'
to 'C:\oracle\oradata\ddba120\USERS01.DBF' ;

SQL> alter database open;

SQL> select tablespace_name, file_name, status from dba_data_files
where tablespace_name='USERS' ;

------------------
USERS
C:\ORACLE\ORADATA\DDBA120\USERS01.DBF
AVAILABLE

datafile 관리하기

1. Logical Database Structure
 

-Segement :  data, index, rollback, temporary
-보통 Oracle block=db_block 는 OS block 의 2배가 적당

2. SYSTEM and Non-SYSTEM Tablespace
   - SYSTEM Tablespace : data dictionary 정보, SYSTEM rollback segment
   - Non-SYSTEM Tablespace : Rollback segments, Temporary segments, App' data, App' index

3. CREATE TABLESPACE

   CREATE TABLESPACE tablespace
      DATAFILE filespec [autoextend_clause]
      [,       filespec [autoextend_clause]]...
      [MINIMUM EXTENT integer [K|M]]
      [DEFAULT storage_clause]
      [PERMANENT|TEMPOARY]    -- default PERMANENT
      [ONLINE|OFFLINE]        -- default ONLINE

   예) CREATE TABLESPACE app_data
       DATAFILE '/DISK4/app01.dbf' SIZE 100M,
                '/DISK5/app02.dbf' SIZE 100M
       MINIMUM EXTENT 500K
       DEFAULT STORAGE (INITIAL 500K NEXT 500K
                        MAXEXTENTS 500 PCTINCREASE 0) ;

   * Storage Parameters
     - INITIAL : first extent의 size를 정한다. 최소 size는 2blocks이다. (2 * DB_BLOCK_SIZE)
           default는 5 bolcks (5 * DB_BLOCK_SIZE)
     - NEXT : 다음 extent의 size를 정한다. 최소 size는 1block 이다.
           default는 5 bolcks (5 * DB_BLOCK_SIZE)
     - MINEXTENTS : segment가 생성되었을 때 할당된 extent의 갯수.
           default는 1
     - PCTINCREASE n : 다음에 extent가 생성될 때 이전 extent보다 n% 증가된 size (PCT: percent)
           default는 50
     - MAXEXTENTS : segment가 갖을 수 있는 extent의 최대 수

4. Temporary Tablespace
  
   CREATE TABLESPACE sort
   DATAFILE '/DISK2/sort01.dbf' SIZE 50M
   MINIMUM EXTENT 1M
   DEFAULT STORAGE (INITIAL 2M NEXT 2M
                    MAXEXTENTS 500 PCTINCREASE 0)
   TEMPORARY ;

5. Tablespace의 size 설정 (data file을 추가하면서...)

   ALTER TABLESPACE app_data
   ADD DATAFILE
       '/DISK5/app03.dbf' SIZE 200M ;

6. Data File이 꽉차면 자동으로 datafile을 증가하게 만드는 방법.

   ALTER TABLESPACE app_data
   ADD DATAFILE
       '/DISK6/app04.dbf' SIZE 200M
   AUTOEXTEND ON NEXT 10M
   MAXSIZE 500M ;

   * 3가지 방법이 있다.
     1) CREATE DATABASE
     2) CREATE TABLESPACE DATAFILE
     3) ALTER TABLESPACE ADD DATAFILE

7. 기존에 존재하는 datafile의 size를 resize하는 방법

   ALTER DATABASE DATAFILE
         '/DISK5/app02.dbf' RESIZE 200M ;

8. Changing the Storage Settings

   ALTER TABLESPACE app_data
   MINIMUM EXTENT 2M ;

   ALTER TABLESPACE app_data
   DEFAULT STORAGE
      (INITIAL 2M NEXT 2M
       MAXEXTENTS 999) ;

9. Tablespace OFFLINE/ONLINE
   - tablespace가 만들어지면 default가 ONLINE이다.
   - OFFLINE이 되면 다른 user의 access가 불가능하다.
   - SYSTEM tablespace는 OFFLINE이 불가!
   - transaction이 끝나지 않은 tablespace는 OFFLINE 불가!

   ALTER TABLESPACE tablespace
     { ONLINE | OFFLINE [NORMAL|TEMPORARY|IMMEDIATE] }
   - Normal : checkpoint를 적용시키고 offline한다.
   - Temporary : datafile 중에서 online datafile에만 checkpoint를 적용시키고 offline한다.
   - Immediate : checkpoint 없이 offline한다.

   예) ALTER TABLESPACE app_data OFFLINE ;

10. Moving Data File : ALTER TABLESPACE
   - 반드시 offline 한 상태에서 한다.
   - target data file이 반드시 존재해야 한다.

   ALTER TABLESPACE app_data
   RENAME DATAFILE '/DISK4/app01.dbf'
   TO              '/DISK5/app01.dbf' ;

11. Moving Data File : ALTER DATABASE
   - 반드시 database가 mount 상태여야 한다.
   - target data file이 반드시 존재해야 한다.
   - shutdown하고 host상태에서 datafile을 제거해야 한다.

   ALTER DATABASE RENAME FILE
         '/DISK1/system01.dbf' TO '/DISK2/system01.dbf' ;

12. READ-ONLY Tablespace 상태
   - 오직 select만 할 수 있다.
   - CREATE는 안되고... DROP은 할 수 있다.
   - user들이 data변경을 못하고, backup과 recovery가 쉽다.

   ALTER TABLESPACE app_data
   READ ONLY

   ALTER TABLESPACE app_data
   READ WRITE   -- read only 상태를 다시 read write상태로 바꿔준다.

   * 주의점!
     - tablespace가 반드시 online상태여야 한다.
     - active transaction이 허용되지 않아야 한다.
     - tablespace가 active rollback segment를 갖고 있으면 안된다.
     - online backup중엔 못한다.

13. DROP TABLESPACE
   - file 삭제는 host에 나가서 삭제를 해야 한다.

   DROP TABLESPACE app_data
   INCLUDING CONTENTS AND DATAFILES;
  
   * including contents를 안썼을 때, tablespace가 비워져 있어야만 drop이 된다.
     including contents는 데이터가 들어 있어도 tablespace를 삭제하겠다는 뜻이다.

14. DBA_TABLESPACES : tablespace 정보를 갖고 있다.
   - TABLESPACE_NAME, NEXT_EXTENT, MAX_EXTENTS, PCT_INCREASE, MIN_EXTLEN, STATUS, CONTENTS

   SVRMGR> SELECT tablespace_name, initial_extent, next_extent,
        2         max_extents, pct_increase, min_extlen
        3    FROM dba_tablespaces ;

15. DBA_DATA_FILES : file에 관한 정보를 갖고 있다.
   - FILE_NAME, TABLESPACE_NAME, BYTES, AUTOEXTENSIBLE, MAXBYTES, INCREMENT_BY

select file_name, tablespace_name, bytes,
autextensible, maxbytes, increment_by
FROM dba_data_files ;

16. Contol File 정보
   - V$DATAFILE : ts#, name, file#, rfile#, status, enabled, bytes, create_bytes
   - V$TABLESPACE : ts#, name

   SVRMGR> SELECT d.file#, d.name, d.status, d.enabled,
        2  d.bytes, d.create_bytes, t.name
        3  FROM v$datafile d, v$tablespace t
        4  WHERE t.ts#=d.ts# ;

17. Temp File Autoextend ON

- autoextend 설정 상태 확인

  SQL > select * from dba_temp_files;  -- temp tablespace


- autoextend on

  SQL > alter database tempfile 'D:\ORACLE\ORADATA\URISVC\LBS_TEMP.ORA' autoextend on next 100M;


데이터파일을 이용해 핫스팟 찾아내기

select name, phyrds, phywrts  from v$datafile a, v$filestat b   where a.file#=b.file#

데이블스페이스에 공간할당해도 extent가 안될 때

select tablespace_name, sum(bytes), max(bytes) from dba_free_space  group by tablespace_name;

데이터 파일 확인하는 법

테이블스페이스 정보

-          dba_tablespaces

-          v$tablespace

테이터 파일 정보

-          dba_data_files

-          v$datafile

임시 파일 정보

-          dba_temp_files

-          v$tempfile

-          

select file_name, tablespace_name, bytes from dba_data_files;


테이블스페이스에 데이터파일 크기 키우기

alter database

datafile ‘/oradata2/RMTESTDB/tools/tools01.dbf’ resize 500M;



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

[ Lab ]


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

1. 현재의 Tablespace와 Data file들을 확인하십시오.
$ sqlplus system/manager
SQL> select * from dba_tablespaces ;
SQL> select file_name, tablespace_name, bytes
  2  from dba_data_files ;
 
2. DATA01 tablespace의 size를 늘이기 위하여, datafile을 하나 더 추가하십시오.
SQL> alter tablespace data01
  2  add datafile '$ORACLE_HOME/DATA/DISK6/data01b.dbf' size 500k ;
SQL> select file_name, tablespace_nmae, bytes
  2  from dba_data_files ;
 
3. 문제2 에서 추가한 datafil의 size를 1M 로 resize 하십시오.
SQL> alter database datafile
  2  '$ORACLE_HOME/DATA/DISK6/data01b.dbf'
  3  resize 1M ;
SQL> select file_name, tablespace_name, bytes
  2  from dba_data_files ;
 
4. 문제2 에서 추가한 datafile의 size가 자동적으로 extend 될 수 있도록 하십시오.
SQL> alter database datafile
  2  '$ORACLE_HOME/DATA/DISK6/data01b.dbf'
  3  autoextend on next 100k maxsize 2m ;
SQL> select file_name, tablespace_name, bytes, autoextensible
  2  from dba_data_files ;
 
5. INDX01 tablespace의 datafile을 DISK6으로 옮기시오.
SQL> alter tablespace indx01 offline ;
SQL> select name, status from v$datafile ;
SQL> host
$ mv $ORACLE_HOME/DATA/DISK3/indx01.dbf $ORACLE_HOME/DATA/DISK6/indx01.dbf
$ exit
SQL> alter tablespace indx01 rename datafile
  2  '$ORACLE_HOME/DATA/DISK3/indc01.dbf'
  3  to
  4  '$ORACLE_HOME/DATA/DISK6/indx01.dbf' ;
SQL> alter tablespace indx01 online ;
SQL> select name, status from v$datafile ;

6. RONLY Tablespace를 read only로 바꾸고, 추가적인 테이블을 생성해 보십시오. 무슨 일이 발생하며 이유는 무엇입니까?
SQL> create table t1(t1 number) tablespace ronly ;
SQL> alter tablespace ronly read only ;
SQL> select name, enabled, status from v$datafile ;
SQL> create table t2(t2 number) tablespace ronly ;    ==> error 발생 확인!

7. RONLY Tablespace를 삭제하십시오.
SQL> drop tablespace ronly including contents ;
SQL> select * from v$tablespace ;
SQL> host

$ rm $ORACLE_HOME/DATA/DISK1/ronly.dbf

EX>
 

데이터 파일 추가

alter tablespace INDX1

add datafile '/oradata10/indx02.dbf'

size 2000M,

'/oradata10/indx03.dbf'

size 2000M,

'/oradata10/indx04.dbf'

size 2000M,

'/oradata10/indx05.dbf'

size 2000M;

alter tablespace H

add datafile ‘/oradata2/H2.dbf’

size 200M

alter tablespace I

add datafile ‘/oradata3/I2.dbf’

size 200M

alter tablespace J

add datafile ‘/oradata4/J2.dbf’

size 200M

alter tablespace K

add datafile ‘/oradata5/K2.dbf’

size 200M

alter tablespace L

add datafile ‘/oradata6/L2.dbf’

size 200M

alter tablespace M

add datafile ‘/oradata2/M2.dbf’

size 200M

alter tablespace N

add datafile ‘/oradata3/N2.dbf’

size 200M

alter tablespace O

add datafile ‘/oradata4/O2.dbf’

size 200M

alter tablespace P

add datafile ‘/oradata5/P2.dbf’

size 200M

alter tablespace Q

add datafile ‘/oradata6/Q2.dbf’

size 200M



TEMP TABLESPACE가 꽉 찾을 경우

/* 임시 테이블스페이스 TEMP9를 새로 만든다.  */

CREATE TEMPORARY TABLESPACE TEMP9 TEMPFILE
  'C:\ORACLE\ORADATA\JJUDB\TEMP09.DBF' SIZE 846M AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;

EX)

alter user JJU_POS temporary tablespace TEMP9;


select 'alter user '|| username||' temporary tablespace temp9;' from all_users;

/* 다음으로 기본 임시 테이블스페이스를 새로 만든걸로 바꿉니다.  */
alter database default temporary tablespace temp9;


drop tablespace temp including contents ;

--Oracle 9i 이상부터는 기본적으로 System tablespace는 LOCAL이다
--9i 이전은 DICTIONARY 이었다.

만일 기존 temp가 돌고 있는 경우...

오라클 내렸다 MOUNT 상태에서 DROP 하고 데이타베이스 OPEN한다.

SQL> startup mount
ORACLE 인스턴스가 시작되었습니다.

Total System Global Area  135338868 bytes
Fixed Size                   453492 bytes
Variable Size             109051904 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
데이터베이스가 마운트되었습니다.
SQL> alter database datafile 'C:\ORACLE\ORADATA\JJUDB\DATA\BSC_D.DBF' offline d
op ;

데이타베이스가 변경되었습니다.

SQL> drop tablespace bsc_i_ts ;
drop tablespace bsc_i_ts
*
1행에 오류:
ORA-01109: 데이터베이스가 개방되지 않습니다


SQL> alter database open ;

데이타베이스가 변경되었습니다.


default temporary tablespace 변경하기

No. 12096

(9I) DEFAULT TEMPORARY TABLESPACE의 개념과 사용 예제
===================================================

PURPOSE
-------

   Space Management와 관련된 Oracle 9i의 새로운 기능 중 Default
   Temporary Tablespace에 대하여 알아보기로 한다.


Explanation
-----------

데이터베이스 user를 생성할 때, 명시적으로 Temporary Tablespace를 지정하
지 않으면 기본적으로 SYSTEM 테이블스페이스가 할당되고, 모든 temporary
data는 이 SYSTEM 테이블스페이스에 저장된다. 9i에서는 데이터베이스 전체
에 걸쳐 사용될 Default Temporary Tablespace로 임의의 Temporary
Tablespace를 정의할 수 있다.

만일 별도의 Temporary Tablespace를 생성하고, 이를 Default Temporary
Tablespace로 지정하면 Temporary data를 저장할 공간으로 불필요하게
SYSTEM 테이블스페이스를 사용할 이유가 없게 된다. (데이터베이스 생성 시
정의할 수 있다.)
데이터베이스 운영 중 아래와 같이 동적으로 변경할 수 있으며, 이 경우 기
존 사용자의 Default Temporary Tablespace도 함께 변경이 된다.

SQL> ALTER DATABASE ora9i DEFAULT TEMPORARY TABLESPACE dts2;

Temporary type으로 만든 datafile은 dba_temp_files view를 보면 된다.


Restrictions on Default Temporary Tablespace
--------------------------------------------

­새로운 Default Temporary Tablespace가 가용하기 전에 기존 Default
Temporary Tablespace를 drop할 수 없다.

­Default Temporary Tablespace를 Permanent Tablespace로 변경할 수 없다.
Default Temporary Tablespace는 SYSTEM Tablespace이거나 Temporary Type
Tablespace이어야만 한다.

­Default Temporary Tablespace는 OFFLINE으로 변경될 수 없다.


Example
-------

As SYSTEM
- 원래대로 Default Temporary Tablespace를 SYSTEM으로 복원

SQL> alter database ora9i default temporary tablespace system;


- 데이터베이스 user 생성 시 Temporary Tablespace 확인:SYSTEM tablespace
  사용

SQL> create user omf_test identified by omf_test;

SQL> select username, temporary_tablespace from dba_users where
     username = 'OMF_TEST'

USERNAME                       TEMPORARY_TABLESPACE
------------------------------ ----------------------------------------
OMF_TEST                       SYSTEM


- Default Temporary Tablespace를 TEMP tablespace(temporary type)로
  변경 :
  기존 사용자(OMF_TEST)의 Temporary Tablespace가 SYSTEM에서 TEMP로 변경
  됨을 알 수 있다.

SQL> alter database ora9i default temporary tablespace temp;

SQL> select username, temporary_tablespace from dba_users where
     username = 'OMF_TEST'

USERNAME                       TEMPORARY_TABLESPACE
------------------------------ ----------------------------------------
OMF_TEST                       TEMP


- 이제는 데이터베이스 user를 생성할 때, Temporary Tablespace가 SYSTEM이
  아닌 TEMP가 됨을 확인

SQL> drop user omf_test;

SQL> create user omf_test identified by omf_test;

SQL> select username, temporary_tablespace from dba_users where
     username = 'OMF_TEST'

USERNAME                       TEMPORARY_TABLESPACE
------------------------------ ----------------------------------------
OMF_TEST                       TEMP

SQL> drop user omf_test;


Reference Documents
-------------------
<Note:138212.1>

<데이타 파일별 용량 확인 쿼리>

SELECT  SYSDATE "Check Time",
                  b.file_name "FILE_NAME",
                  b.tablespace_name "TABLESPACE_NAME",
                  TO_CHAR((b.bytes / 1024),'999,990,999') "TOTAL SIZE(KB)", -- 총 Bytes
                  TO_CHAR((((b.bytes - sum(nvl(a.bytes,0)))) / 1024),'999,990,999') "USED(KB)",
                  TO_CHAR(((sum(nvl(a.bytes,0))) / 1024),'999,990,999') "FREE SIZE(KB)",
                  TRUNC(((sum(nvl(a.bytes,0)) / (b.bytes)) * 100),2) "FREE %"
                  FROM DBA_FREE_SPACE a, DBA_DATA_FILES b
WHERE a.file_id(+) = b.file_id
GROUP BY b.tablespace_name, b.file_name, b.bytes
ORDER BY b.tablespace_name;

 
[출처 Bywoong Blog]
반응형
Posted by [PineTree]
ORACLE/SQL2009. 9. 11. 20:52
반응형
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
char[(n)]
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
유니코드가 아니고, 길이가 n바이트인 고정 길이 문자 데이터입니다. n은 1에서 8,000 사이의 값이어야 하고 저장소 크기는 n바이트입니다. char의 SQL-92 동의어는 character입니다.


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
varchar[(n)]
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
유니코드가 아니고, 길이가 n바이트인 가변 길이 문자 데이터입니다. n은 1에서 8,000 사이의 값이어야 하고 저장소 크기는 n바이트가 아니라 입력한 데이터의 실제 바이트 길이입니다. 입력한 데이터의 길이는 0일 수 있습니다. varchar의 SQL-92 동의어는 char varying 또는 character varying입니다.
비고

데이터 정의나 변수 선언문에서 n을 지정하지 않으면 기본 길이는 1입니다. CAST 함수에 n을 지정하지 않으면 기본 길이는 30입니다.

char이나 varchar을 사용하는 개체는 COLLATE 절을 사용하여 특정 데이터 정렬을 할당하지 않는 한 데이터베이스의 기본 데이터 정렬이 할당됩니다. 데이터 정렬은 문자 데이터를 저장하는 데 사용하는 코드 페이지를 제어합니다.

여러 언어를 지원하는 사이트는 문자 변환 문제를 최소화하기 위해 유니코드 nchar 또는 nvarchar 데이터 형식을 사용하는 것을 고려해야 합니다. char 또는 varchar을 사용하는 경우,

    * 열의 데이터 값이 크기가 비슷할 경우 char를 사용합니다.
    * 열의 데이터 값이 크기가 다를 경우 varchar를 사용합니다.

CREATE TABLE 또는 ALTER TABLE을 실행할 때 SET ANSI_PADDING이 OFF면 NULL로 정의된 char 열이 varchar로 처리됩니다.

데이터 정렬 코드 페이지에서 더블바이트 문자를 사용할 경우 저장소 크기는 계속 n바이트입니다. 문자열에 따라 n바이트의 저장소 크기가 n자보다 작을 수도 있습니다.


자료출처 : http://cafe.naver.com/q69.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=22995


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
VARCHAR2 와  NVARCHAR2
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
VARCHAR2 타입은, 데이터베이스의 character set 데이터를 가변 길이로 저장하고, NVARCHAR2 타입은 데이터베이스의 national character set 데이터를 가변 길이로 저장하는데 사용되는 데이터 타입입니다.
NVARCHAR2 타입도 NCHAR 타입과 같이 Oracle 9i 이상 버전에서는 UNICODE를 사용하여야만 합니다. 따라서 UTF8이나 AL16UTF16만 가능합니다.

VARCHAR2 나 NVARCHAR2 의 주된 특징은, 컬럼 정의 시 지정된 max length보다 적은 길이의 문자열을 저장하는 경우, Empty Byte가 SPACE로 추가 (padding) 되지 않고, 실제 data만 저장되는 가변 길이라는 것입니다. 그래서 CHAR/NCHAR에 비해 불필요한 자원 낭비를 막고, 테이블에 대한 Full Scan시에도 작은블록을 읽어 성능상 장점이 있으며, Empty Block이 PADDING되지 않아 정확한 비교를 하는데 유의해야 할사항이 적습니다.

VARCHAR2 Data Type은 최대 4000byte까지 저장이 가능하며 , 자릿수는 반드시 지정해야 합니다.
한 편 NVARCHAR2 Data Type도 최대 4000byte까지 저장이 가능한데, 자릿수를 지정하지 않을 경우 한글자가 지정됩니다. 저장되는 National Character Set에 따라 AL16UTF16의 경우엔 2 BYTE, UTF8의 경우는 3BYTE가 기본입니다.

내부 저장방식을 dump() function으로 확인해 보면, VARCHAR2 및 NVARCHAR2 의 내부 데이터 코드값은 1 입니다. 이 내부코드 값으로 Data Type에 대한 식별이 가능합니다.

Length는 실제 data를 insert한 양에 따라 유동적입니다. CHAR/NCHAR에 비해 불필요한 space가 추가되지 않았음을 확인할 수 있습니다.
실제로 저장된 문자data는 각 문자의 ASCII CODE값만 저장되었음을 확인이 하실 수 있습니다.

참고>
참고로 VARCHAR2와 NVARCHAR2의 dump결과 내부코드가 같으나, 구별은 table description으로
column에 정의된 Data Type에 대한 확인이 가능하며, 또한 한글의 경우 저장된 byte로도 확인이 가능합니다.
예를 들어 DB characterset이 KO16KSC5601이고 national characterset이 UTF8인 경우,
“가”를 저장한다고 보면, varchar2 Data Type의 length는 2byte이나 nvarchar2 Data Type은 3byte로 보입니다.
물론 DB characterset과 national characterset이 같은 UTF8인 경우엔 column에 정의된 Data
Type으로만 확인이 가능합니다.


자료출처 : http://blog.naver.com/redfreek2c?Redirect=Log&logNo=120028930188
반응형

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

NVL,DECODE  (0) 2010.01.03
constraint 제약조건 (primary, foreign , unique,check, default)  (0) 2009.11.02
ROLLUP , CUBE , GROUPING  (0) 2009.09.02
Oracle 널값(null)에 대하여 정리  (0) 2009.08.21
SELECT문 및 연산자  (0) 2009.08.10
Posted by [PineTree]
ORACLE/ADMIN2009. 9. 11. 20:42
반응형
Index of This Note:
-------------------

1) What is the National Character Set?
2) Which datatypes use the National Character Set?
3) How to know if I use N-type columns?
4) Should I worry when I upgrade from 8i or lower to 9i, 10g or 11g?
5) The NLS_NCHAR_CHARACTERSET is NOT changed to UTF8 or AL16UTF16 after upgrading to 9i.
6) Can I change the AL16UTF16 to UTF8 / I hear that there are problems with AL16UTF16.
7) Is the AL32UTF8 problem the same as the AL16UTF16 / do I need the same patches?
8) But I still want <characterset> as NLS_NCHAR_CHARACTERSET, like I had in 8(i)!
9) Do i need to set NLS_LANG to AL16UTF16 when creating/using the NLS_NCHAR_CHARACTERSET ?
10) I try to use AL32UTF8 as NLS_NCHAR_CHARACTERSET but it fails with ORA-12714
11) I have the message "( possible ncharset conversion )" during import.
12) Can i use AL16UTF16 as NLS_CHARACTERSET ?
13) I'm inserting <special character> in a Nchar or Nvarchar2 col but it comes back as ? ...
14) Do i need to change the NLS_NCHAR_CHARACTERSET in 8i to UTF8 BEFORE upgrading to 9i/10g?
15) Having a UTF8 NLS_CHARACTERSET db is there a advantage to use AL16UTF16 N-types ?
16) I have a message in the DBUA (Database Upgrade Assistant) about NCHAR type when upgrading from 8i..
17) How to go from an UTF8 NLS_NCHAR_CHARTERSET to AL16UTF16?

1) What is the National Character Set?
--------------------------------------

The National Character set (NLS_NCHAR_CHARACTERSET) is a character set
which is defined in addition to the (normal) database character set and
is used for data stored in NCHAR, NVARCHAR2 and NCLOB columns.

Your current value for the NLS_NCHAR_CHARACTERSET can be found with this select:

select value from NLS_DATABASE_PARAMETERS where parameter='NLS_NCHAR_CHARACTERSET';

You cannot have more than 2 charactersets defined in Oracle:
The NLS_CHARACTERSET is used for CHAR, VARCHAR2, CLOB columns;
The NLS_NCHAR_CHARACTERSET is used for NCHAR, NVARCHAR2, NCLOB columns.

NLS_NCHAR_CHARACTERSET is defined when the database is created
and specified with the CREATE DATABASE command.
The NLS_NCHAR_CHARACTERSET defaults to AL16UTF16 if nothing is specified.

From 9i onwards the NLS_NCHAR_CHARACTERSET can have only 2 values:
UTF8 or AL16UTF16 who are Unicode charactersets.
See Note 260893.1 Unicode character sets in the Oracle database
for more info about the difference between them.

Al lot of people think that they *need* to use the NLS_NCHAR_CHARACTERSET to have
UNICODE support in Oracle, this is not true, NLS_NCHAR_CHARACTERSET (NCHAR, NVARCHAR2)
is in 9i always Unicode but you can perfectly use "normal" CHAR and VARCHAR2 columns for storing unicode
in a database who has a AL32UTF8 / UTF8 NLS_CHARACTERSET.
See also point 15.

When trying to use another NATIONAL characterset the CREATE DATABASE command will
fail with "ORA-12714 invalid national character set specified"

The character set identifier is stored with the column definition itself.

2) Which datatypes use the National Character Set?
--------------------------------------------------

There are three datatypes which can store data in the national character set:

NCHAR - a fixed-length national character set character string.
The length of the column is ALWAYS defined in characters
(it always uses CHAR semantics)

NVARCHAR2 - a variable-length national character set character string.
The length of the column is ALWAYS defined in characters
(it always uses CHAR semantics)

NCLOB - stores national character set data of up to four gigabytes.
Data is always stored in UCS2 or AL16UTF16, even if the
NLS_NCHAR_CHARACTERSET is UTF8.
This has very limited impact, for more info about this please see:
Note 258114.1 Possible action for CLOB/NCLOB storage after 10g upgrade
and if you use DBMS_LOB.LOADFROMFILE see
Note 267356.1 Character set conversion when using DBMS_LOB

If you don't know what CHAR semantics is, then please read
Note 144808.1 Examples and limits of BYTE and CHAR semantics usage

If you use N-types, DO use the (N'...') syntax when coding it so that Literals are
denoted as being in the national character set by prefixing letter 'N',
for example:

create table test(a nvarchar2(100));
insert into test values(N'this is a NLS_NCHAR_CHARACTERSET string');


3) How to know if I use N-type columns?
---------------------------------------

This select list all tables containing a N-type column:

select distinct OWNER, TABLE_NAME from DBA_TAB_COLUMNS where DATA_TYPE in ('NCHAR','NVARCHAR2', 'NCLOB');

On a 9i database created without (!) the "sample" shema you will see these rows (or less) returned:

OWNER TABLE_NAME
------------------------------ ------------------------------
SYS ALL_REPPRIORITY
SYS DBA_FGA_AUDIT_TRAIL
SYS DBA_REPPRIORITY
SYS DEFLOB
SYS STREAMS$_DEF_PROC
SYS USER_REPPRIORITY
SYSTEM DEF$_LOB
SYSTEM DEF$_TEMP$LOB
SYSTEM REPCAT$_PRIORITY

9 rows selected.

These SYS and SYSTEM tables may contain data if you are using:

* Fine Grained Auditing -> DBA_FGA_AUDIT_TRAIL
* Advanced Replication -> ALL_REPPRIORITY, DBA_REPPRIORITY, USER_REPPRIORITY
DEF$_TEMP$LOB , DEF$_TEMP$LOB and REPCAT$_PRIORITY
* Advanced Replication or Deferred Transactions functionality -> DEFLOB
* Oracle Streams -> STREAMS$_DEF_PROC


If you do have created the database with the DBCA and included
the sample shema then you will see typically:

OWNER TABLE_NAME
------------------------------------------------------------
OE BOMBAY_INVENTORY
OE PRODUCTS
OE PRODUCT_DESCRIPTIONS
OE SYDNEY_INVENTORY
OE TORONTO_INVENTORY
PM PRINT_MEDIA
SYS ALL_REPPRIORITY
SYS DBA_FGA_AUDIT_TRAIL
SYS DBA_REPPRIORITY
SYS DEFLOB
SYS STREAMS$_DEF_PROC
SYS USER_REPPRIORITY
SYSTEM DEF$_LOB
SYSTEM DEF$_TEMP$LOB
SYSTEM REPCAT$_PRIORITY

15 rows selected.

The OE and PM tables contain just sample data and can be dropped if needed.

4) Should I worry when I upgrade from 8i or lower to 9i, 10g or 11g?
--------------------------------------------------------------------

* When upgrading from version 7:

The National Character Set did not exist in version 7,
so you cannot have N-type columns.
Your database will just have the -default- AL16UTF16 NLS_NCHAR_CHARACTERSET
declaration and the standard sys/system tables.
So there is nothing to worry about...

* When upgrading from version 8 and 8i:

- If you have only the SYS / SYSTEM tables listed in point 3)
then you don't have USER data using N-type columns.

Your database will just have the -default- AL16UTF16 NLS_NCHAR_CHARACTERSET
declaration after the upgrade and the standard sys/system tables.
So there is nothing to worry about...

We recommend that you follow this note:
Note 159657.1 Complete Upgrade Checklist for Manual Upgrades from 8.X / 9.0.1 to Oracle9i

- If you have more tables then the SYS / SYSTEM tables listed in point 3)
(and they are also not the "sample" tables) then there are 3 possible cases:

* Again, the next to points are *only* relevant when you DO have n-type USER data *

a) Your current 8 / 8i NLS_NCHAR_CHARACTERSET is in this list:

JA16SJISFIXED , JA16EUCFIXED , JA16DBCSFIXED , ZHT32TRISFIXED
KO16KSC5601FIXED , KO16DBCSFIXED , US16TSTFIXED , ZHS16CGB231280FIXED
ZHS16GBKFIXED , ZHS16DBCSFIXED , ZHT16DBCSFIXED , ZHT16BIG5FIXED
ZHT32EUCFIXED

Then the new NLS_NCHAR_CHARACTERSET will be AL16UTF16
and your data will be converted to AL16UTF16 during the upgrade.

We recommend that you follow this note:
Note 159657.1 Complete Upgrade Checklist for Manual Upgrades from 8.X / 9.0.1 to Oracle9i

b) Your current 8 / 8i NLS_NCHAR_CHARACTERSET is UTF8:

Then the new NLS_NCHAR_CHARACTERSET will be UTF8
and your data not be touched during the upgrade.

We still recommend that you follow this note:
Note 159657.1 Complete Upgrade Checklist for Manual Upgrades from 8.X / 9.0.1 to Oracle9i

c) Your current 8 / 8i NLS_NCHAR_CHARACTERSET is NOT in the list of point a)
and is NOT UTF8:

Then your will need to export your data and drop it before upgrading.
We recommend that you follow this note:
Note 159657.1 Complete Upgrade Checklist for Manual Upgrades from 8.X / 9.0.1 to Oracle9i

For more info about the National Character Set in Oracle8 see Note 62107.1

5) The NLS_NCHAR_CHARACTERSET is NOT changed to UTF8 or AL16UTF16 after upgrading to 9i.
----------------------------------------------------------------------------------------

That may happen if you have not set the ORA_NLS33/ORA_NLS10 environment parameter
correctly to the 9i/10g Oracle_Home during the upgrade.
Note 77442.1 ORA_NLS (ORA_NLS32, ORA_NLS33, ORA_NLS10) Environment Variables explained.

You may see errors like "ORA-12714: invalid national character set specified"

We recommend that you follow this note for the upgrade:
Note 159657.1 Complete Upgrade Checklist for Manual Upgrades from 8.X / 9.0.1 to Oracle9i

Strongly consider to restore your backup and do the migration again or log a
TAR, refer to this note and ask to assign the TAR to the NLS/globalization
team. That team can then assist you further.

However please do note that not all situations can be corrected,
so you might be asked to do the migration again...

Note: do NOT use the UTLNCHAR.SQL or N_SWITCH.SQL script!
This will not help and make things only worse...

Provide the output of this select:

select distinct OWNER, TABLE_NAME, DATA_TYPE from DBA_TAB_COLUMNS where DATA_TYPE in ('NCHAR','NVARCHAR2', 'NCLOB');

when logging a SR.

6) Can I change the AL16UTF16 to UTF8 / I hear that there are problems with AL16UTF16.
--------------------------------------------------------------------------------------

6a) If you do *not* use N-types then there is NO problem at all with AL16UTF16
because you are simply not using it and we strongly advice you the keep
the default AL16UTF16 NLS_NCHAR_CHARACTERSET.

6b) If you *do* use N-types then there will be a problem with 8i clients and
lower accessing the N-type columns (note that you will NOT have a problem
selecting from "normal" non-N-type columns).
More info about that is found there:
Note 140014.1 ALERT Oracle8/8i to Oracle9i/10g using New "AL16UTF16" National Character Set
Note 236231.1 New Character Sets Not Supported For Use With Developer 6i And Older Versions

If this is a situation you find yourself in we recommend to simply use UTF8
as NLS_NCHAR_CHARACTERSET or create a second 9i db using UTF8 as NCHAR and use this as "inbetween" between the 8i and the 9i db
you can create views in this new database that do a select from the AL16UTF16 9i db
the data will then be converted from AL16UTF16 to UTF8 in the "inbetween" database and that can
be read by oracle 8i

This is one of the 2 reasons why you should use UTF8 as NLS_NCHAR_CHARACTERSET.
If you are NOT using N-type columns with pre-9i clients then there is NO reason to go to UTF8.

6c) If you want to change to UTF8 because you are using transportable tablespaces from 8i database
then check if are you using N-types in the 8i database that are included in the tablespaces that you are transporting.

select distinct OWNER, TABLE_NAME from DBA_TAB_COLUMNS where DATA_TYPE in ('NCHAR','NVARCHAR2', 'NCLOB');

If yes, then you have the second reason to use UTF8 as as NLS_NCHAR_CHARACTERSET.

If not, then leave it to AL16UTF16 and log a tar for the solution of the ORA-19736
and refer to this document. (see also point 8 in this note)

6D) You are in one of the 2 situations where it's really needed to change from
AL16UTF16 to UTF8 then the correct steps to go from AL16UTF16 to UTF8 are:

6D1) install csscan:

Note 458122.1 Installing and configuring CSSCAN in 8i and 9i
Note 745809.1 Installing and configuring CSSCAN in 10g and 11g

6D2) For 9i:

* export all the user N-data

* drop/truncate all the user N-data
-- If you do not drop all N-data then you will run into
-- ORA-12717: Cannot issue ALTER DATABASE NATIONAL CHARACTER SET when NCLOB, NCHAR or NVARCHAR2 data exists

* run csscan to check if everything is ok

csscan FULL=Y TONCHAR=UTF8 LOG=check CAPTURE=Y ARRAY=1000000 PROCESS=2

aways run csscan with / as sydba

* csscan will ask:


Current database character set is UTF8. <- this is the current NLS_CHARACTERSET

Enter new database character set name: > <-*just hit enter here*


* check that you see in the check.txt file this:

All character type data in the data dictionary remain the same in the new character set
All character type application data remain the same in the new character set


* then you can do a ALTER DATABASE NATIONAL CHARACTER SET UTF8;
Shutdown the listener and any application that connects locally to the database.
There should be only ONE connection the database during the WHOLE time and that's
the sqlplus session where you do the change.

1. Make sure the parallel_server parameter in INIT.ORA is set to false or it is not set at all.
If you are using RAC see
Note 221646.1 Changing the Character Set for a RAC Database Fails with an ORA-12720 Error

2. Execute the following commands in sqlplus connected as "/ AS SYSDBA":

SPOOL Nswitch.log
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER SYSTEM ENABLE RESTRICTED SESSION;
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
ALTER SYSTEM SET AQ_TM_PROCESSES=0;
ALTER DATABASE OPEN;
ALTER DATABASE NATIONAL CHARACTER SET UTF8;
SHUTDOWN IMMEDIATE;

3. Restore the parallel_server parameter in INIT.ORA, if necessary.

* import the user N-data again

6D3) for 10g and up:

* export any user N-data
* drop/truncate any user N-data
* Truncate these 2 xdb tables if

SQL>select LOCALNAME from XDB.XDB$QNAME_ID;
SQL>select NMSPCURI from XDB.XDB$NMSPC_ID;

gives 7 rows

SQL>truncate table XDB.XDB$QNAME_ID
SQL>truncate table XDB.XDB$NMSPC_ID

if you have more rows log a SR.

* run csscan to check if everything is ok

csscan FULL=Y TONCHAR=UTF8 LOG=check CAPTURE=Y ARRAY=1000000 PROCESS=2

always run csscan with / as sydba

* csscan will ask:


Current database character set is UTF8. <- this is the current NLS_CHARACTERSET

Enter new database character set name: > <-*just hit enter here*


* check that you see in the check.txt file this:

All character type data in the data dictionary remain the same in the new character set
All character type application data remain the same in the new character set

* after that run csalter ( using alter database is in a 10g system for the national characterset not really a problem, but csalter is the official way)

Shutdown the listener and any application that connects locally to the database.
There should be only ONE connection the database during the WHOLE time and that's
the sqlplus session where you do the change.

Then you do in sqlplus connected as "/ AS SYSDBA":


-- Make sure the parallel_server and CLUSTER_DATABASE parameter are set
-- to false or it is not set at all.
-- If you are using RAC you will need to start the database in single instance
-- with CLUSTER_DATABASE = FALSE
sho parameter CLUSTER_DATABASE
sho parameter PARALLEL_SERVER
-- check if you are using spfile
sho parameter pfile
-- if this "spfile" then you are using spfile
-- in that case note the
sho parameter job_queue_processes
sho parameter aq_tm_processes
-- (this is Bug 6005344 fixed in 11g )
-- then do

shutdown immediate
startup restrict
SPOOL Nswitch.log
@@?\rdbms\admin\csalter.plb
-- if you are using spfile then you need to also
-- ALTER SYSTEM SET job_queue_processes=<original value> SCOPE=BOTH;
-- ALTER SYSTEM SET aq_tm_processes=<original value> SCOPE=BOTH;

shutdown
startup


* after this update the XDB tables again with these inserts:

(these inserts can also be found in the $ORACLE_HOME/rdbms/admin/catxdbtm.sql script)

insert into xdb.xdb$nmspc_id values ('http://www.w3.org/XML/1998/namespace', HEXTORAW('01'));
insert into xdb.xdb$nmspc_id values ('http://www.w3.org/XML/2000/xmlns', HEXTORAW('02'));
insert into xdb.xdb$nmspc_id values ('http://www.w3.org/2001/XMLSchema-instance', HEXTORAW('03'));
insert into xdb.xdb$nmspc_id values ('http://www.w3.org/2001/XMLSchema', HEXTORAW('04'));
insert into xdb.xdb$nmspc_id values ('http://xmlns.oracle.com/2004/csx', HEXTORAW('05'));
insert into xdb.xdb$nmspc_id values ('http://xmlns.oracle.com/xdb', HEXTORAW('06'));
insert into xdb.xdb$nmspc_id values ('http://xmlns.oracle.com/xdb/nonamespace', HEXTORAW('07'));

insert into xdb.xdb$qname_id values (HEXTORAW('01'), 'space', HEXTORAW('01'), HEXTORAW('10'));
insert into xdb.xdb$qname_id values (HEXTORAW('01'), 'lang', HEXTORAW('01'), HEXTORAW('11'));
insert into xdb.xdb$qname_id values (HEXTORAW('03'), 'type', HEXTORAW('01'), HEXTORAW('12'));
insert into xdb.xdb$qname_id values (HEXTORAW('03'), 'nil', HEXTORAW('01'), HEXTORAW('13'));
insert into xdb.xdb$qname_id values (HEXTORAW('03'), 'schemaLocation', HEXTORAW('01'), HEXTORAW('14'));
insert into xdb.xdb$qname_id values (HEXTORAW('03'), 'noNamespaceSchemaLocation', HEXTORAW('01'), HEXTORAW('15'));
insert into xdb.xdb$qname_id values (HEXTORAW('02'), 'xmlns', HEXTORAW('01'), HEXTORAW('16'));

commit;

* import any user N-data


important:

Do NOT use the UTLNCHAR.SQL or N_SWITCH.SQL script.
Using this a to try to go from UTF8 to AL16UTF16 (or inverse)
will corrupt existing NCHAR data !!!!!!
It is to be used only in specific conditions when upgrading from 8i to 9i

7) Is the AL32UTF8 problem the same as the AL16UTF16 / do I need the same patches?
----------------------------------------------------------------------------------
No, they may look similar but are 2 different issues.

For information about the possible AL32UTF8 issue please see
Note 237593.1 Problems connecting to AL32UTF8 databases from older versions (8i and lower)

8) But I still want <characterset> as NLS_NCHAR_CHARACTERSET, like I had in 8(i)!
---------------------------------------------------------------------------------

This is simply not possible.

From 9i onwards the NLS_NCHAR_CHARACTERSET can have only 2 values: UTF8 or AL16UTF16.

Both UTF8 and AL16UTF16 are unicode charactersets, so they can
store whatever <characterset> you had as NLS_NCHAR_CHARACTERSET in 8(i).

If you are not using N-types then keep the default AL16UTF16 (or use UTF8 if you really want),
it doesn't matter if you don't use the N-types.

There is one condition in which this "limitation" can have a undisired affect,
when you are importing an Oracle8i Transportable Tablespace into Oracle9i
you can run into a ORA-19736 (as wel with AL16UTF16 as with UTF8).

Simply provide the 8i output of:

select distinct OWNER, TABLE_NAME from DBA_TAB_COLUMNS where DATA_TYPE in ('NCHAR','NVARCHAR2', 'NCLOB');

In that case log a TAR, refer to this note and ask to assign the TAR to the
NLS/globalization team. That team can then assist you to work around this
issue in a easy way.
Do NOT try to change the national characterset in 8i to AL16UTF16 or update system tables
like you find sometimes on "oracle dba sites" on the internet if you don't want to
test your backup strategy.

9) Do i need to set NLS_LANG to AL16UTF16 when creating/using the NLS_NCHAR_CHARACTERSET ?
------------------------------------------------------------------------------------------

As clearly stated in
Note 158577.1 NLS_LANG Explained (How does Client-Server Character Conversion Work?)
point "1.2 What is this NLS_LANG thing anyway?"

* NLS_LANG is used to let Oracle know what characterset you client's OS is USING
so that Oracle can do (if needed) conversion from the client's characterset to the
database characterset.

NLS_LANG is a CLIENT parameter has has no influence on the database side.

10) I try to use AL32UTF8 as NLS_NCHAR_CHARACTERSET but it fails with ORA-12714
-------------------------------------------------------------------------------

From 9i onwards the NLS_NCHAR_CHARACTERSET can have only 2 values:
UTF8 or AL16UTF16.

UTF8 is possible so that you can use it (when needed) for 8.x backwards compatibility.
In all other conditions AL16UTF16 is the preferred and best value.
AL16UTF16 has the same unicode revision as AL23UTF8,
so there is no need for AL32UTF8 as NLS_NCHAR_CHARACTERSET.

11) I have the message "( possible ncharset conversion )" during import.
------------------------------------------------------------------------

in the import log you see something similar to this:

Import: Release 9.2.0.4.0 - Production on Fri Jul 9 11:02:42 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to: Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
JServer Release 9.2.0.4.0 - Production
Export file created by EXPORT:V08.01.07 via direct path
import done in WE8ISO8859P1 character set and AL16UTF16 NCHAR character set
export server uses WE8ISO8859P1 NCHAR character set (possible ncharset conversion)

This is normal and is not a error condition.

- If you do not use N-types then this is a pure informative message.

- But even in the case that you use N-types like NCHAR or NCLOB then this is not a problem:

* the database will convert from the "old" NCHAR characterset to the new one automatically.
(and - unlike the "normal" characterset - the NLS_LANG has no impact on this conversion
during exp/imp)

* AL16UTF16 or UTF8 (the only 2 possible values in 9i) are unicode characterset and so
can store any character... So no data loss is to be expected.

12) Can i use AL16UTF16 as NLS_CHARACTERSET ?
----------------------------------------------

No, AL16UTF16 can only be used as NLS_NCHAR_CHARACTERSET in 9i and above.
Trying to create a database with a AL16UTF16 NLS_CHARACTERSET will fail.

13) I'm inserting <special character> in a Nchar or Nvarchar2 col but it comes back as ? ...
--------------------------------------------------------------------------------------------------

see point 14 in Note 227330.1 Character Sets & Conversion - Frequently Asked Questions

14) Do i need to change the NLS_NCHAR_CHARACTERSET in 8i to UTF8 BEFORE upgrading to 9i/10g?
--------------------------------------------------------------------------------------------

No, see point 4) in this note.

15) Having a UTF8 NLS_CHARACTERSET db is there a advantage to use AL16UTF16 N-types ?
-------------------------------------------------------------------------------------

There might be 2 reasons:

a) one possible advantage is storage (disk space) for NCHAR/NVARCHAR2.

UTF8 uses 1 up to 3 bytes, AL16UTF16 always 2 bytes.

If you have a lot of non-western data (cyrillic, Chinese, Japanese, Hindi languages..)
then it can be advantageous to use N-types for those columns seen those characters will use
3 bytes in UTF8 and 2 bytes in AL16UTF16.

For western data (english, french, spanish, dutch, german, portuguese etc...)
UTF8 will use in most cases less disk space then AL16UTF16.

Note 260893.1 Unicode character sets in the Oracle database

This is NOT true for NCLOB and CLOB, they are both encoded a internal fixed-width Unicode character set
Note 258114.1 Possible action for CLOB/NCLOBrage after 10g upgrade
so they will use the same amount of disk space.

b) other possible advantage is extending the limits of CHAR semantics

For a single-byte character set encoding, the character and byte length are
the same. However, multi-byte character set encodings do not correspond to
the bytes, making sizing the column more difficult.

Hence the reason why CHAR semantics was introduced. However, we still have some
physical underlying byte based limits and development has choosen to allow full usage
of the underlying limits. This results in the following table giving the maximum amount
of CHARarcters occupying the MAX datalength that can be stored for a certain
datatype in 9i and up.

The MAX colum is the MAXIMUM amount of CHARACTERS that can be stored
occupying the MAXIMUM data length. Seen that UTF8 and AL32UTF8 are VARRYING
charactersets this means that a string of X chars can be X to X*3 (or X*4 for AL32) bytes.

The MIN col is the maximum size that you can *define* and that Oracle can store if all data
is the MINIMUM datalength (1 byte for AL32UTF8 and UTF8) for that characet.

N-types (NVARCHAR2, NCHAR) are *always* defined in CHAR semantics, you cannot define them in BYTE.

All numbers are CHAR definitions.


UTF8 (1 to 3 bytes) AL32UTF8 (1 to 4 bytes) AL16UTF16 ( 2 bytes)
MIN MAX MIN MAX MIN MAX
CHAR 2000 666 2000 500 N/A N/A

VARCHAR2 4000 1333 4000 1000 N/A N/A

NCHAR 2000 666 N/A N/A 1000 1000

NVARCHAR2 4000 1333 N/A N/A 2000 2000

(N/A means not possible)

This means that if you try to store more then 666 characters
that occupy 3 bytes in UTF8 in a CHAR UTF8 colum you still will get a
ORA-01401: inserted value too large for column
(or from 10g onwards: ORA-12899: value too large for column )
error, even if you have defined the colum as CHAR (2000 CHAR)
so here it might be a good idea to define that column as NCHAR
that will raise the MAX to 1000 char's ...

Note 144808.1 Examples and limits of BYTE and CHAR semantics usage

Disadvantages using N-types:

* You might have some problems with older clients if using AL16UTF16
see point 6) b) in this note
* Be sure that you use (AL32)UTF8 as NLS_CHARACTERSET , otherwise you will run into
point 13 of this note.
* Do not expect a higher *performance* by using AL16UTF16, it might be faster
on some systems, but that has more to do with I/O then with the database kernel.
* Forms 6i/9i does not support NCHAR / NVARCHAR2.
This is documented in the 6i Forms online help.
and in Note 258195.1 Oracle9 Features not yet Supported in Forms 9i
* If you use N-types, DO use the (N'...') syntax when coding it so that Literals are
denoted as being in the national character set by prepending letter 'N', for example:

create table test(a nvarchar2(100));
insert into test values(N'this is NLS_NCHAR_CHARACTERSET string');

Normally you will choose to use Char/Varchar2 (using a (AL32)UTF8 NLS_CHARACTERSET)
for simplicity, to avoid confusion and possible other limitations who might be
imposed by your application or programming language to the usage of N-types.

16) I have a message running DBUA (Database Upgrade Assistant) about NCHAR type when upgrading from 8i .
--------------------------------------------------------------------------------------------------------

see point 16 in Note 227330.1 Character Sets & Conversion - Frequently Asked Questions

17) How to go from an UTF8 NLS_NCHAR_CHARTERSET to AL16UTF16?
-------------------------------------------------------------

Befor going from UTF8 to AL16UTF16 you need to see that you don't have any
NCHAR bigger then 1000 CHAR or NVARCHAR2 column bigger then 2000 CHAR

select distinct OWNER, TABLE_NAME, COLUMN_NAME, CHAR_LENGTH from DBA_TAB_COLUMNS where DATA_TYPE='NCHAR' and CHAR_LENGTH > 1000;
select distinct OWNER, TABLE_NAME, COLUMN_NAME, CHAR_LENGTH from DBA_TAB_COLUMNS where DATA_TYPE='NVARCHAR2' and CHAR_LENGTH > 2000;

or the ALTER DATABASE NATIONAL CHARACTER SET AL16UTF16; / Csalter will fail

You will need to adapt those columns after exporting the User N-data (if any).

you can ignore for the moment SYS.DBA_FGA_AUDIT_TRAIL|SQL_TEXT if this is 4000 and change to AL16UTF16
-> select CHAR_LENGTH from DBA_TAB_COLUMNS where OWNER='SYS' and TABLE_NAME='DBA_FGA_AUDIT_TRAIL' and COLUMN_NAME='SQL_TEXT';
And then after the change to AL16UTF16 run SQL> @?\rdbms\admin\catfga.sql

The procedure is just the same as in point 6D) simply use AL16UTF16 instead of UTF8 as characterset.

Related Documents:
------------------
Note 62107.1 The National Character Set in Oracle8
Note 227330.1 Character Sets & Conversion - Frequently Asked Questions
Note 227332.1 NLS considerations in Import/Export - Frequently Asked Questions

Note 158577.1 NLS_LANG Explained (How does Client-Server nversion Work?)
Note 159657.1 Complete Upgrade Checklist for Manual Upgrades from 8.X.0.1 to Oracle9i
Note 278725.1 utlnchar.sql and n_switch.sql fail with ORA-01735 on "non-standard" object names
Note 260893.1 Unicode character sets in the Oracle database
Note 144808.1 Examples and limits of BYTE and CHAR semantics usage

Note 237593.1 Problems connecting to AL32UTF8 databases from older versions (8i and lower)
Note 140014.1 ALERT Oracle8/8i to Oracle9i using New "AL16UTF16" National Character Set
Note 236231.1 New Character Sets Not Supported For Use With Developer 6i And Older Versions

Note 258114.1 Possible action for CLOB/NCLOB storage after 10g upgrade
Note 267356.1 Character set conversion when using DBMS_LOB

For further NLS / Globalization information you may start here:
Note 60134.1 Globalization Technology (NLS) - Frequently asked Questions
반응형
Posted by [PineTree]
ORACLE/SCRIPT2009. 9. 11. 14:15
반응형
select *
from 테이블
where case when m_stpdesc < 'ㄱ' then SUBSTR(m_stpdesc, 1, 1)
            when ascii('ㄱ') <= ascii(m_stpdesc) and
                 ascii(m_stpdesc)<= ascii('ㅎ') then m_stpdesc
            when m_stpdesc < '나' then 'ㄱ'
            when m_stpdesc < '다' then 'ㄴ'
            when m_stpdesc < '라' then 'ㄷ'
            when m_stpdesc < '마' then 'ㄹ'
            when m_stpdesc < '바' then 'ㅁ'
            when m_stpdesc < '사' then 'ㅂ'
            when m_stpdesc < '아' then 'ㅅ'
            when m_stpdesc < '자' then 'ㅇ'
            when m_stpdesc < '차' then 'ㅈ'
            when m_stpdesc < '카' then 'ㅊ'
            when m_stpdesc < '타' then 'ㅋ'
            when m_stpdesc < '파' then 'ㅌ'
            when m_stpdesc < '하' then 'ㅍ'
            else                  'ㅎ'
       end = 'ㄹ' ;    <<=================찾고자하는 자음


m_stpdesc <<===========해당 컬럼

반응형
Posted by [PineTree]
ORACLE/INSTALL2009. 9. 7. 21:30
반응형
I. Hardware:
===========
  1. Minimum Hardware Requirements
    a.) At least 1.0 Gb (1024 MB) of physical RAM
    b.) Swap disk space proportional to the system's physical memory as follows: 

         RAM                                Swap Space
         1024 Mb to 2048 Mb      1.5 x RAM
         2049 Mb to 16 Gb           1 x RAM 
         greater than 16 Gb            16 Gb

    c.) 1024 Mb of disk space (and less than 2Tb of disk space) in the /tmp directory.
    d.) 3.8 Gb of local disk space for the database software.
    e.) 1.7 Gb of disk space for a preconfigured database that uses file system storage (optional)


II. Software:
============
  1. As is specified in section 1.3.1 of the Oracle Database Installation Guide for 11gR2 on Linux (part number E10840-01), Oracle recommends that you install the Linux operating system with the default software packages (RPMs) and do not customize the RPMs during installation. For additional information on "default-RPMs", please see Note 376183.1, "Defining a "default RPMs" installation of the RHEL OS"

  2. Red Hat Enterprise Linux AS/ES 4 update 7 (or greater), which is Kernel 2.6.9-78.EL or newer.

  3. Required OS Components (per Release Notes, and Install Guide)
    a.) The exact version number details of this list are based upon 64-bit (x86-64) RHEL AS 4 update 7. When a newer "update" level is used, the RPM release numbers (such as 2.6.9-78) may be slightly higher (such as 2.6.9-83 or 2.6.9-95). Since RHEL AS/ES 4 "update" levels of "update 7" and beyond are certified, this is fine so long as you are still using 64-bit Linux (x86-64) RHEL AS/ES 4 RPMs.
    b.) Some of the Install Guide requirements will already be present from the "default-RPMs" foundation of Linux that you started with:
        1.) binutils-2.15.92.0.2-25 (x86_64)
        2.) compat-libstdc++-33-3.2.3-47.3 (x86_64) << both ARCH's are required. See next line.
        3.) compat-libstdc++-33-3.2.3-47.3 (i386) << both ARCH's are required. See previous line.
        4.) elfutils-libelf-0.97.1-5 (x86_64)
        5.) expat-1.95.7-4 (x86_64)
        6.) glibc-2.3.4-2.41 (x86_64) << both ARCH's are required. See next line.
        7.) glibc-2.3.4-2.41 (i686) << both ARCH's are required. See previous line.
        8.) glibc-common-2.3.4-2.41 (x86_64)
        9.) libaio-0.3.105-2 (i386) << both ARCH's are required. See next section.
        10.) libgcc-3.4.6-10 (x86_64) << both ARCH's are required. See next line.
        11.) libgcc-3.4.6-10 (i386) << both ARCH's are required. See previous line.
        12.) libstdc++-3.4.6-10 (x86_64) << both ARCH's are required. See next line.
        13.) libstdc++-3.4.6-10 (i386) << both ARCH's are required. See previous line.
        14.) make-3.80-7.EL4 (x86_64)
        15.) pdksh-5.2.14-30.6 (x86_64)
        16.) unixODBC-2.2.11-1.RHEL4.1 (x86_64) << both ARCH's are required. See next line.
        17.) unixODBC-2.2.11-1.RHEL4.1 (i386) << both ARCH's are required. See previous line.


    c.) The remaining Install Guide requirements will have to be installed:
        1.) elfutils-libelf-devel-0.97.1-5.x86_64.rpm
        2.) glibc-headers-2.3.4-2.41.x86_64.rpm will be required as a prerequisite
            a.) glibc-kernheaders-2.4-9.1.103.EL.x86_64.rpm will be required as a prerequisite
        3.) glibc-devel-2.3.4-2.41.x86_64.rpm << both ARCH's are required. See next section.
        4.) gcc-3.4.6-10.x86_64.rpm
        5.) libaio-0.3.105-2.x86_64.rpm << both ARCH's are required. See previous section.
        6.) libaio-devel-0.3.105-2.x86_64.rpm << both ARCH's are required. See next line.
        7.) libaio-devel-0.3.105-2.i386.rpm << both ARCH's are required. See previous line.
        8.) libstdc++-devel-3.4.6-10.x86_64.rpm
        9.) gcc-c++-3.4.6-10.x86_64.rpm 
      10.) sysstat-5.0.5-19.el4.x86_64.rpm
      11.) unixODBC-devel-2.2.11-1.RHEL4.1.x86_64.rpm << both ARCH's are required. See next line.
      12.) unixODBC-devel-2.2.11-1.RHEL4.1.i386.rpm << both ARCH's are required. See previous line.

  4. Additional Required OS Components (per the runInstaller OUI)
    a.) intentionally blank

  5. Additional Required OS Components (per this NOTE)
    a.) Please do not rush, skip, or minimize this critical step. This list is based upon a "default-RPMs" installation of 64-bit (x86-64) RHEL AS/ES 4. Additional RPMs (beyond anything known to Oracle) may be needed if a "less-than-default-RPMs" installation of 64-bit (x86-64) RHEL AS/ES 4 is performed. For more information, please refer to Note 376183.1, "Defining a "default RPMs" installation of the RHEL OS"
    b.) glibc-devel-2.3.4-2.41.i386.rpm << both ARCH's are required. See previous section.
    c.) Several RPMs will be required as prerequisites to those listed in section II.3.c:
        1.) glibc-kernheaders-2.4-9.1.103.EL.x86_64.rpm
        2.) itentionally blank

  6. Oracle Global Customer Support has noticed a recent trend with install problems that originates from installing too many RPMs. For example:
    a.) installing your own JDK version (prior to beginning the Oracle Software “runInstaller”) is not needed on Linux, and is not recommended on Linux. A pre-existing JDK often interferes with the correct JDK that the Linux Oracle Software “runInstaller” will place and use.
    b.) installing more than the required version of the gcc / g++ RPMs often leads to accidentally using (aka enabling or activating) the incorrect one. If you have multiple RDBMS versions installed on the same Linux machine, then you will likely have to manage multiple versions of gcc /g++ . For more information, please see Note 444084.1, "Multiple gcc / g++ Versions in Linux"

  7. All of the RPMs in section II. are on the Red Hat Enterprise Linux AS/ES 4 64-bit (x86-64) distribution media.

III. Environment:
================
  1. Modify your kernel settings in /etc/sysctl.conf (RedHat) as follows. If the current value for any parameter is higher than the value listed in this table, do not change the value of that parameter. Range values (such as net.ipv4.ip_local_port_range) must match exactly.
    kernel.shmall = physical RAM size / pagesize For most systems, this will be the value 2097152. See Note 301830.1 for more information.
    kernel.shmmax = 1/2 of physical RAM, but not greater than 4GB. This would be the value 2147483648 for a system with 4Gb of physical RAM.
    kernel.shmmni = 4096
    kernel.sem = 250 32000 100 128
    fs.file-max = 512 x processes (for example 6815744 for 13312 processes)
    fs.aio-max-nr = 1048576
    net.ipv4.ip_local_port_range = 9000 65500
    net.core.rmem_default = 262144
    net.core.rmem_max = 4194304
    net.core.wmem_default = 262144
    net.core.wmem_max = 1048576 

  2. To activate these new settings into the running kernel space, run the “sysctl –p” command

  3. The gcc and g++ RPM items above will ensure that the correct gcc / g++ versions are installed. It is also required that you ensure that these correct gcc / g++ versions are active, and in-use. Ensure that the commands "gcc --version" and "g++ --version" each return "3.4.x".

  4. Set Shell Limits for the oracle User. Assuming that the "oracle" Unix user will perform the installation, do the following:

    a.) Add the following settings to /etc/security/limits.conf
         oracle soft nproc 2047
         oracle hard nproc 16384
         oracle soft nofile 1024
         oracle hard nofile 65536

    b.) Add or edit the following line in the /etc/pam.d/login file, if it does not already exist:
         session required pam_limits.so

    c.) Add the following lines to /etc/profile:
         if [ $USER = "oracle" ]; then 
            if [ $SHELL = "/bin/ksh" ]; then
               ulimit -p 16384
               ulimit -n 65536
            else
               ulimit -u 16384 -n 65536
            fi
         fi


  5. The hostname command should return the fully qualified hostname as shown
below:
      % hostname 
          hostname.domainname

  6. If any Java packages are installed on the system, unset the Java environment variables, for example JAVA_HOME.

  7. The oracle account used to install Oracle 11.2.0.1, should not have the Oracle install related variables set by default. For example setting ORACLE_HOME, PATH, LD_LIBRARY_PATH to include Oracle binaries in .profile, .login file and /etc/profile.d should be completely avoided.
    a.) Setting $ORACLE_BASE (not $ORACLE_HOME) is recommended, since it eases a few prompts in the OUI runInstaller tool.
    b.) following the succesful install, it is recommended to set $ORACLE_HOME, and to set $PATH to include the Oracle binaries ($ORACLE_HOME/bin) as the first location.

  8. Log in as Oracle user and start the installation as follows:
     ./runInstaller

    a.) When performing the 11.2.0.1 installation, make sure to use the "runInstaller" version that comes with 11.2.0.1 software. 
    b.) When performing any subsequent 11.2.0.x patchset, make sure to use the "runInstaller" version that comes with the patchset. 
    c.) it is best practice not to use any form of "su" to start the runInstaller, in order to avoid potential display-related problems



ADDITIONAL NOTES
----------------
1. Supported distributions of the 32-bit (x86) Linux OS can run on on AMD64/EM64T and Intel Processor Chips that adhere to the x86_64 architecture
  a.) Oracle 32-bit running on AMD64/EM64T with 32-bit OS is supported, but is NOT covered by this NOTE.
  b.) Oracle 32-bit running on AMD64/EM64T with 64-bit OS is not certified and is not supported.

2. Asynchronous I/O on ext2 and ext3 file systems is supported if your scsi/fc driver supports that functionality.

3. No extra patch is required for the DIRECTIO support for x86-64.

4. No LD_ASSUME_KERNEL value should be used with the 11gR2 product.

5. Following rpm command can be used to distinguish between a 32-bit or 64-bit package.
    #rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n" | grep glibc-devel
     glibc-devel-2.3.4-2.41 (i386)
     glibc-devel-2.3.4-2.41 (x86_64)
반응형
Posted by [PineTree]
OS/LINUX2009. 9. 7. 21:29
반응형
256MB의 스왑파일을 만들어 보겠습니다. 먼저 스왑파일을 만들 공간을 설정합니다. 다음과 같은 명령을 내리면 /boot 디렉토리 밑에 256MB짜리 NULL 파일이 만들어 집니다. /dev/zero는 Null byte의 source를 뜻하며 생성하고자 하는 swap파일의 명칭은 편의상 swapfile로 하였습니다.
#dd if=/dev/zero of=/boot/swapfile bs=1024 count=262144


만든 파일이 스왑파일로 작동할 수 있도록 설정을 합니다. v0 옵션은 old 스타일이고, v1은 new 스타일입니다.
#mkswap -v1 /boot/swapfile

활성화를 시킵니다.
#swapon /boot/swapfile

free명령으로 스왑영역이 늘어난 것을 확인할 수 있습니다.
#free


부팅 시 스왑공간이 활성화되게 하려면 /etc/fstab 파일에 아래 한 줄을 추가합니다.
/boot/swapfile swap swap defaults 1 1
반응형

'OS > LINUX' 카테고리의 다른 글

리눅스 rm삭제햇을 때 복구  (0) 2009.11.06
RedHat Linux Network 설정하기  (0) 2009.10.29
Linux 성능 조정 - tcp  (0) 2009.03.13
RHEL 4 에 YUM 설치  (0) 2009.02.10
LINUX 해킹당했을 때 대처요령  (0) 2008.11.17
Posted by [PineTree]
ORACLE/SCRIPT2009. 9. 4. 16:46
반응형
반응형
Posted by [PineTree]
ORACLE/ORACLE TOOL2009. 9. 4. 14:22
반응형

SQL * Plus 명령어  & 환경 시스템 변수

                                                                           - By Everekk79 ( Last Updated 2007.11.22 )

 

sqlplus [ username [ /password [ @database ]]

 

SQL*Plus 명령어는 한번에 한 라인만 입력할 수 있으며 명령어를 축약하여 사용할 수 있다.

SQL*Plus 명령어는 SQL 버퍼에 저장되지 않으며 세미콜론(;)과 같은 종료 문자를 사용하지 않는다.

 

RUN : 최근에 실행된 SQL 명령문을 실행한다

         SQL 명령문과 함께 결과를 출력한다

/ : 최근에 실행된 SQL 명령문을 실행한다.

    검색 결과만을 출력한다.

  ==> 최근에 실행된 SQL 명령문은 SQL 버퍼에 저장되어 있 다.

 

eixt : 정상 종료

  ==> 정상 종료를 해야만 사용자가 데이터베이스에 수정한 내용이 디스크에 영구적으로 저장된다.

 

 

▣ 시스템 변수 설정 명령어

 

 SET System_Variable Value

 

Set Auto [Commit] { off | on | imm[ediate] | n }

on, immediate : DML 명령문이 성공적으로 실행되면 자동적으로 Commit 명령문 실행

off : DML 명령문 실행 후, 사용자가 직접 Commit 명령문 실행

n : DML 명령문을 n 번 성공적으로 실행 후 자동적으로 Commit 문 실행 

 

Set Feed[back] { 6 | n | off | on }

Select 문의 실행 결과를 표시하기 위하여 출력 행의 수를 지정하는 시스템 변수

n : 출력 행의 수가 n 이상인 경우만  " n개의 행이 선택되었습니다" 라는 메시지 출력

6 : 기본값

on : feedback 변수 값을 기본값으로 설정한다.

 

Set Heading { off | on }

off : 컬럼 제목이 출력되지 않는다.

on : 컬럼 제목을 출력한다.

 

Set Lin[esize] { 80 | n }

한 화면에 표시되는 SQL 명령문의 출력 결과에 대한 행의 크기를 설정한다.

기본값은 80이며 최대값은 시스템에 따라 차이가 남

 

Set Pages[ize] { 14 | n }

한 화면에 표시되는 SQL 명령문의 실행 결과에 대한 페이지의 크기를 설정하기 위한 시스템 변수

한 페이지에는 칼럼 제목, 데이터의 구분선, 페이지를 구분하기 위한 공백 라인도 포함된다.

기본값은 14이다,

 

Set Pause { off | on }

SQL 명령문의 실행 결과를 한 화면에 보기 힘든 경우에 한 페이지씩 나누어 출력하기 위한 시스템 변수이다.

on : 사용자가 엔터키를 입력할 때까지 대기하고 있다가 엔터 키를 입력하면 실행 결과를 출력한다.

 

Set Term[out] { off | on }

SQL 명령문 실행 결과를 화면에 출력할 지 여부를 지정하기 위한 시스템 변수

스크립트(*.sql) 파일에 의해 실행된 여러 개의 SQL 명령문의 출력 결과를 확인 할 필요가 없는 경우 유용하게 사용된다.

off : SQL 명령문의 실행 결과가 화면에 출력되지 않는다.

on : SQL 명령문의 실행 결과를 화면에 출력한다.

 

Set Ti[me] { off | on }

SQL  프롬프트 앞에 시스템의 현재 시간을 함께 표시하도록 설정하는 시스템 변수

on : SQL 프롬프트 앞에 시간 정보가 함께 표시된다.

off : 시간 정보를 출력되지 않도록 설정한다.

 

Set Timing { off | on }

Timing  변수는 SQL 명령문을 실행하는데 소요된 시간을 출력하기 위한 시스템 변수이다.

시간은 '시:분:초.밀리초' 형식으로 출력된다.

on : SQL 명령문을 실행하는데 소요된 시간을 출력한다,

off : 소요된 시간 정보가 출력되지 않는다.

 

Set Und[erline] { - | c | on | off }

컬럼 제목과 데이터간의 구분 기호를 설정하기 위한 시스템변수이다.

c : 모든 문자

on : 구분기호 사용

off : 구분기호 사용하지 않음

 

Set Verify { on | off }

SQL 명령문이나 PL/SQL에서 &를 이용한 치환 변수등을 사용할 때 치환되기 전 후의 자세한 값을

보일 건지의 여부를 결정한다. 기본값은 On이다

 

Set Serveroutput { on | off }

PL/SQL 문에서 dbms_output.put_line() 프로시저를 사용

출력을 SQL*Plus 에서 보려면 Set Serveroutput on 을 먼저 실행해야 한다.

 

Set Colsep { text }

컬럼이 표시될때 컬럼의 구별 문자

열 사이에 출력되는 문자를 설정

Default Value : 공백

 

▣ SQL*Plus 기타 명령어

 

Show { system_variable | all }

Show 명령문은 현재 세션에 설정된 시스템 변수를 확인하기 위한 명령어이다.

Show all을 할 경우 현재 설정된 모든 환경 변수값을 확인 할수 있다.

 

Help 명령어

SQL 명령어를 모를 경우 사용

 

 

▣ 형식 명령어

 

Column { column | alias } [ option ] [ Format ]

Column 명령어는 SQL 명령문의 실행 결과로 출력되는 칼럼 제목이나 컬럼 데이터에 대한 출력 형식을 다양하게 지정하기 위한 명령어이다.

[ option ]

Cle[ar] : 컬럼 형식 해제

For[mat] fromat : 컬럼 데이터의 출력 형식 지정

Hea[ding] text : 컬럼 제목 설정, text 내의 수직(|)바는 컬럼 제목을 여러 줄로 출력 할 경우

                       EnterKey 역활

Jus[tify] { align } : 컬럼 제목을 왼쪽, 가운데 또는 오른쪽 정렬

Nopri[nt] : 컬럼 숨기기

pri[nt] : 컬럼 출력하기

Nul[l] text : null값에 대한 출력 문자 지정

[ Format ]

An : 문자 형식 컬럼의 출력 크기를 n폭으로 설정

9 :  단일 zero-suppression (0억제) 숫자

      example >> 999999 -> 1234

0 : 지정된 길이만큼 숫자 앞에 0 추가

      example >> 009999 -> 001234

$ : 숫자 앞에 달러 기호 삽입

      example >> $9999 -> $1234

L : 숫자 앞에 지역 화폐단위 삽입

      example >> L9999  -> $1234

. :  소숫점 위치 지정

      example >> 9999.99  -> 1234.00

, : 1000 자리마다 ',' 구분자 삽입

      example >> 9,999 -> 1,234

 

 

SQL> help variable

 VARIABLE
 --------

 Declares a bind variable that can be referenced in PL/SQL, or
 lists the current display characteristics for a single variable
 or all variables.

VAR[IABLE] [variable [type]]

 where type represents one of the following:

     NUMBER         CHAR          CHAR (n [CHAR|BYTE])
     NCHAR          NCHAR (n)     VARCHAR2 (n [CHAR|BYTE])
     NVARCHAR2 (n)  CLOB          NCLOB
     REFCURSOR      BINARY_FLOAT  BINARY_DOUBLE

 

 

▣ 편집 명령어

 

A[ppend] text : SQL 버퍼의 현재 라인 끝에 text 추가

C[hange]/old/new : 현재 라인의 old text를 new text로 변경

C[hange]/text/ : 현재 라인에서 text 삭제

Cl[ear] Buff[er] : 모든 라인 삭제

Del : 현재 라인 삭제

Del n : n 번째 라인 삭제

Del m n : m 번째 라인에서 n 라인까지 Text 삭제

I[nput] : 현재 라인 다음에 text 추가

I[nput] text : 현재 라인 다음에 text 추가

L[ist] : 모든 라인 출력

L[ist] n : n번째 라인의 text 출력

L[ist] m n : m번째 라인부터 n 라인까지 text 출력

n : n 번째 라인으로 이동

n text : n 번째 라인 내용으로 text 변경

0 text : 1번째 라인 앞에 text 추가

 

▣ 파일 조작 명령어

 

Sav[e] filename : 현재 SQL 버퍼의 내용을 파일에 저장

Get filename :  Save 명령어로 저장한 파일을 SQL 버퍼에 읽어 옴

Sta[rt] filename : 파일을 일고 즉시 실행

@filename : 파일을 읽고 즉시 실행

Ed[it] filename : 저장된 파알 내용을 편집

Spo[ol] [filename | off | on ] : 파일에 출력 결과를 저장

                                            off 는 spool 파일을 닫음

                                            on 은 spool 파일을 닫고 프린터로 파일 전송

반응형
Posted by [PineTree]
ORACLE/INSTALL2009. 9. 4. 09:44
반응형
오라클 DB에서 한글을 사용하다보면 정렬에 관한 문제가 발생하는 경우가 있다. 특히 동양권(한국/일본) 언어에서는 자국에 원어이외에 한자를 사용하고 있으므로 인해 여러가지 문제가 발생하는 경우가 있다.
 
KO16KSC5601에서 한글 정렬
KO16KSC5601 에서는 한글 2350자의 바이너리 정렬 순서가 한글의 언어적 정렬 방식과 동일하다. 따라서, 단순히 Order by 명령만으로 정렬의 효과를 거둘 수 있다. 한자의 경우 한글 뒤에 한자의 음에 맞게 정렬이 된다.
이것은 단지 한글 2350자들과 한자 4888자의 정렬일뿐이며, 나머지 글자들에 대해서는 입출력도 불가능하다.
 
UTF8/AL32UTF8에서 한글 정렬
UTF8 데이터베이스의 경우, 한글만을 고려하면 별다른 정렬 옵션이 필요없다. 왜냐하면 한글 11172자의 정렬 순서와 바이트 코드 정렬 순서가 일치하기 때문이다.
그러나 한자를 포함한다면 한자->한글 식으로 정렬이 된다.
 
KO16MSWIN949에서 한글 정렬
KO16MSWIN949 는 KO16KSC5601에서 지원되지 않는 8822자의 한글을 추가적으로 지원한다는 점에서 KO16KSC5601의 대안으로 자주 이용되는 Character Set이다. 하지만, 총 11172자의 한글의 바이트 코드가 한글의 언어적 정렬 순서와 불일치 한다.
 
NLS_SORT
UTF8과 KO16MSWIN949에서는 원하는 형태의 정렬이 일어나지 않는다. 이럴 때 NLS_SORT 값을 활용하여 원하는 형태의 정렬을 구현할 수 있다.
NLS_SORT='KOREAN_M'
  -  한글은 단순히 유니코드 바이트 정렬에 의존한다.
  - 모든 한글은 한자에 우선한다.
  - 한자는 발음 순서대로 정렬된다.
한마디로 KO16KSC5601에서 사용되던 정렬 방식으로 모든 한글과 한자를 정렬하겠다는 방법이다.
 
NLS_SORT='UNICODE_BINARY'
이 방법을 사용하면 각각의 문자에 대응하는 이진코드값을 기준으로 정렬된다. 이때는 한자->한글 순이다.
즉, 한글과 한자를 사용하는 경우에는 NLS_SORT='KOREAN_M'을 사용해야 한다.
반응형
Posted by [PineTree]