开发者

How to insert umlaut with correct hex value in Oralce using sqlplus

I have a u umlaut in text file , with the hex dump value

cat /tmp/bb
ü

hexdump /tmp/bb
0000000 bcc3 000a                              
0000003

When I insert the umlaut in the database with a column on type VARCHAR2(128 CHAR)

DUMP(res,1016)
Typ=1 Len=6 CharacterSet=UTF8: ef,bf,bd,ef,bf,bd

Bytes are completely开发者_JS百科 different. (My database is set as UTF8 charset)

Question how do I insert data into the column using sqlplus. Any ideas?


Assuming you mean that you have a u with a diaeresis, not a u with an unmlat, you can use the UNISTR function to enter the UCS-2 code point of the character in SQL*Plus (U+00FC for a u with a diaeresis)

SQL> create table foo (
  2    col1 varchar2(1 char)
  3  );

Table created.

SQL> insert into foo values( unistr('\00fc') );

1 row created.

SQL> ed
Wrote file afiedt.buf

  1  select dump(col1, 1016)
  2*   from foo
SQL> /

DUMP(COL1,1016)
-------------------------------------------------------------

Typ=1 Len=2 CharacterSet=AL32UTF8: c3,bc

If you are just trying to read the data from the file into the database, however, there are likely easier options than converting everything to UCS-2 code points.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜