본문 바로가기
DBMS/ORACLE

NCHAR(national character set) 테스트

by 드바 2022. 10. 7.
- NCHAR byte 아닌 글자 단위 nvarchar2(100) 100글자
- AL32UTF8은 AL16UTF16의 Super Set 이므로 AL32UTF8 DB에서는 사용할 필요 없음
- 영문, 숫자 모두 2byte로 저장되기때문에 공간낭비가 있을 수 있음

 

SQL> SELECT PARAMETER, VALUE FROM NLS_DATABASE_PARAMETERS 
where parameter  IN (
'NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET'
)
;
PARAMETER		       VALUE
------------------------------ ------------------------------
NLS_NCHAR_CHARACTERSET	       AL16UTF16
NLS_CHARACTERSET	       AL32UTF8

-- C1 VARCHAR2, C2 NVARCHAR2로 컬럼 생성
SQL> CREATE TABLE sk.tab2 (c1 varchar(100), c2 nvarchar2(100)) ;
Table created.

SQL> INSERT INTO sk.tab2 VALUES ('abc','abc') ;
1 row created.

SQL> INSERT INTO sk.tab2 VALUES ('123','123') ;
1 row created.

SQL> INSERT INTO sk.tab2 VALUES ('가나다','가나다') ;
1 row created.

SQL> INSERT INTO sk.tab2 VALUES ('!@#','!@#') ;
1 row created.

SQL> commit ;
Commit complete.

SQL> SELECT c1, dump(c1,1016) AS c1d , c2, dump(c2,1016) AS c2d FROM sk.tab2 ;
C1	   C1D										    C2	       C2D
---------- -------------------------------------------------------------------------------- ---------- --------------------------------------------------------------------------------
abc	   Typ=1 Len=3 CharacterSet=AL32UTF8: 61,62,63					    abc        Typ=1 Len=6 CharacterSet=AL16UTF16: 0,61,0,62,0,63
123	   Typ=1 Len=3 CharacterSet=AL32UTF8: 31,32,33					    123        Typ=1 Len=6 CharacterSet=AL16UTF16: 0,31,0,32,0,33
가나다     Typ=1 Len=9 CharacterSet=AL32UTF8: ea,b0,80,eb,82,98,eb,8b,a4                    가나다     Typ=1 Len=6 CharacterSet=AL16UTF16: ac,0,b0,98,b2,e4
!@#	   Typ=1 Len=3 CharacterSet=AL32UTF8: 21,40,23					    !@#        Typ=1 Len=6 CharacterSet=AL16UTF16: 0,21,0,40,0,23

SQL>

 

 

 

 

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

LMS(License Management Services) 체크 스크립트  (0) 2023.06.01
PMO_DEFERRED_GIDX_MAINT_JOB  (0) 2023.06.01
ORACLE 통계정보 백업/복구  (0) 2022.09.06
특정 SQL_ID shared pool 에서 flush 하기  (0) 2022.09.05
OPTIMIZER_DYNAMIC_SAMPLING  (0) 2022.07.06

댓글