INSERTing chinese characters in SQL*plus
Db version: 10gR2
NLS_NCHAR_CHARACTERSET for my DB is AL16UTF16 by which i can store chinese characters. To INSERT using SQL*Plus, i tried to copy and paste some chinese characters from internet. When the characters get pasted, it becomes '?????' (question marks). What else do i have to set to store Chinese characters?
SQL> CREATE TABLE EMP2
2 (EMPNO NUMBER,
3 ENAME NVARCHAR2(500));
Table created.
SQL> Insert into emp2(empno,ename) values(889,UNISTR('????'));
1 row created.
SQL> COMMIT;
Commit complete.
SQL> SELECT * FROM EMP2;
EMPNO ENAME
889 ????
Actually, it looks like Forums do something strange to URLs pasted into posts. Sorry!
The thread URL is Re: store/retrieve data in lang other than eng when CHARACTERSET is not UTF8
Similar Messages
-
Chinese Characters in SQL Plus
Hi, I wonder how do I input the chinese characters in SQL plus? I have set the NLS_LANG value to chinese characterset in the REGEDIT but it doesn't display the chinese characters. Is there any chinese version on Oracle JDeveloper Suite?
Cheersi have installed sqlplus and oracle db in the same PC under chinese win xp.
i found that if you spool the output to a text file, and type in dos-prompt, it still cannot display the chinese character properly. but if you open the text file by notepad, bingo, you can the chinese character.
i think that it is because dos-prompt application is non-unicode application. so it could not display unicode character properly.
as a result, if you want to display unicode character in non-unicode application (run sqlplus under dos-prompt), you have to set the NLS_LANG environment variable which match the character set of non-unicode application which your operating system assigned. in my case, it should be Big5. then oracle would do the conversion for you automatically, i.e. from unicode in DB to Big5 in client.
I either set the NLS_LANG environment variable in one of the 2 ways:
NLS_LANG=american_america.zht16big5 or
NLS_LANG=american_america.zht16hkscs
Regards,
KH -
Displaying Chinese characters in SQL*Plus
DB version: 11.2
OS Version : AIX 6.1
DB characterset:AL32UTF8
To display chinese characters in SQL*Plus, I did the following:
$ export LANG=zh_CN.UTF-8
$ export LC_ALL=zh_CN.GB2312
$ export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
$
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on ÐÇÆÚÈý 5ÔÂ 2 15:52:33 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning option
SQL> ALTER SESSION SET NLS_LANGUAGE='SIMPLIFIED CHINESE';
Session altered.
SQL> ALTER SESSION SET NLS_TERRITORY='CHINA';
Session altered.
SQL> select unistr('\8349') from dual; ---- not 100% sure if this is the way to verify if chinese characters can be displayed.
UN
²Ý ----------------------------------------> Getting a junk character instead of chinese If I was using putty, are the above steps enough to get chinese characters displayed ?
Our ssh client is Tectia (not putty).
According the below ML Note, the SSH client has to configured correctly to use globalization features.
+The correct NLS_LANG setting in Unix Environments [ID 264157.1]+
Googling "Tectia + Chinese" didn't return useful resultsI understand that you are talking about Windows SSH Client.
For Putty, you should set:
$ export LANG=zh_CN.UTF-8
$ export LC_ALL=zh_CN.UTF-8
$ export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
and configure Putty in Window->Translation to use UTF-8.
There is nothing about this subject on Tectia website and in their manuals, so my best guess is that the client requires Windows code page to work correctly. In such case you need to set your Windows system default locale (locale for non-Unicode programs) to Chinese and use the following settings on the server:
$ export LANG=zh_CN.GBK
$ export LC_ALL=zh_CN.GBK
$ export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
Verify with 'locale -a' that the setting zh_CN.GBK is supported on your system.
-- Sergiusz -
Insert chinese characters to mysql
I have searched the forum and found a useful links --http://forum.java.sun.com/thread.jspa?threadID=530358 about inserting chinese characters to mysql. However, I can't see the chinese characters displayed in the db. The charset and collation of my table are utf8 and utf8_bin respectively. Can anyone help me? Below is my source code
------------------ Servet ---------------------
package test;
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class testServlet extends HttpServlet {
private Connection conn;
public void init(ServletConfig config) throws ServletException {
sSysPhyPath = config.getServletContext().getRealPath("/");
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
// set content type and other response header fields first
res.setContentType("text/html");
// get the communication channel with the requesting client
PrintWriter out = res.getWriter();
out.println("<html>");
out.println("<body bgcolor=\"white\">");
out.println("<body>");
req.setCharacterEncoding("UTF-8");
sValue = req.getParameter("s1");
out.println(sValue.getBytes("UTF-8") + "<br>");
DBConnection objConn = new DBConnection(sSysPhyPath);
try {
conn = objConn.get();
objConn.execQuery(conn, "insert into TBL_test (test_desc) values ('" + sValue.getBytes("UTF-8") + "')");
catch(Exception e) {
e.printStackTrace();
objConn.closeConnection(conn);
out.println("</body></html>");
public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
doGet(req, res);
public void destroy() {
--------------- Html ------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#666666">
<form name="test" method="post" action="testServlet">
<input type="text" name="s1">
<input type="Submit" name="Submit" value="Submit">
</form>
</body>
</html>
Besides, if I code the chinese characters directly in the servlet page, what is the encoding of the chinese characters by default? Is it related to my OS locale?
Thanks a lot.objConn.execQuery(conn, "insert into TBL_test
st (test_desc) values ('" + sValue.getBytes("UTF-8")
+ "')");You would be better off using a PreparedStatement and parameters. This will let the MySQL JDBC driver take care of the required encoding. -
Insert chinese characters in oracle81 database(with code here)
Hi all,
I have problem on insert chinese characters in oracle8i database(with code below). But no problem when display chinese characters in HTML( not include in the follow program)
Can anyone help me?????
In unix:
Database setting:
charset: ZHT16BIG5
version:8.1.7
In NT 4.0 with SP5:
web/app server setting
webserver: iWs4.0.1
appserver: iAs6.0
Java 1.2.2 with download classes12.zip/nls_charset12.zip
JDBC thin driver
code:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
import javax.sql.*;
import java.util.*;
import java.lang.*;
import java.lang.reflect.*;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.math.*;
import oracle.sql.*;
public class updatedata extends HttpServlet
Connection dbCon = null;
ResultSet rs = null;
DataSource ds1 = null;
String input_data = "";
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException,IOException{
input_data = req.getParameter("chinese_input");
res.setContentType("text/html; charset=BIG5");
PrintWriter out = res.getWriter();
// draw a table
ConnDB(out);
DrawTable(out);
public void JDBC(PrintWriter out) throws NamingException {
InitialContext ctx = null;
String dsName1 = null;
Connection conn = null;
dsName1 = "jdbc/project";
try {
ctx = new InitialContext();
ds1 = (DataSource)ctx.lookup(dsName1);
}catch (NamingException e) {
out.println("exception in servlet in JDBC : " + e.toString());
/** big5 to unicode conversion **/
private String b2u(String str2convert)
throws IOException {
StringBuffer buffer = new StringBuffer();
byte[] targetBytes = str2convert.getBytes();
ByteArrayInputStream stream = new ByteArrayInputStream(targetBytes);
InputStreamReader isr=new InputStreamReader(stream, "BIG5");
Reader in = new BufferedReader(isr);
int chInt;
while ( (chInt = in.read()) > -1 ) {
buffer.append((char)chInt);
in.close();
return buffer.toString();
private void DrawTable(PrintWriter out){
try{
try{
// update data
String u="update test_chinese set chinese_script=? where prod_cd=?";
String sProd = "T1";
PreparedStatement ps = dbCon.prepareStatement(u);
ps.setString(1, input_data);
ps.setString(2, sProd);
ps.executeUpdate();
dbCon.commit();
catch(SQLException e){
out.println("exception in insert: " + e.toString());
out.println("<html>");
out.println("<body>");
out.println("update success!!!!");
out.println("</body>");
out.println("</html>");
catch(Exception e){
out.println("exception in servlet in statement: " + e.toString());
private Connection ConnDB(PrintWriter out){
try{
try{
JDBC(out);
catch (Exception e) {
out.println("Database connect failed (init)");
out.println(e.toString());
return null;
dbCon = ds1.getConnection();
catch(Exception e){
out.println("exception in servlet in connection: " + e.toString());
return dbCon;
public void destroy() {
//Close database connection
try {
dbCon.close();
catch (Exception e) {
System.out.println("Error closing database (destroy)");
System.out.println(e.toString());Hi, Jenny,
When you said unable to insert to database, do you mean you get all ? marks in the database or garbage characters in the database?
? marks mean there are some byte chop off, and garbage characters mean the bytes are ok, just encoding problem.
--Lichu -
How to Insert Chinese characters in Japanese Database
Hi all,
I am having following characteristics on my computer
Machine OS --Windows Server 2003
OS language --Japanese
Oracle
Oracle9i Release 9.2.0.1.0 - Production
NLS_LANGUAGE JAPANESE
NLS_CHARACTERSET JA16SJIS
Now, i want to insert into database chinese characters. Please guide me how to do the following thing.
How to insert chinese characters on local machine and if i want to insert on the remote databse (i can not create database link for remote database). I have to send batch file or SQL file and they will execute it on their side.
if i use this command
alter session set nls_language = "SIMPLIFIED CHINESE"
and then insert the records and revert back to japanese character set. Is this correct way....?
Thanks in advance,
PalAs dombrooks has pointed out, unless all the Chinese characters you are trying to store can be represented in the Shift-JIS character set, which seems unlikely, but I'm not an expert on East Asian languages and I believe there are some glyphs that are shared between various languages, then you're not going to be able to store this data in this database in CHAR or VARCHAR2 columns.
Depending on the national character set, you may be able to store the data in NCHAR/ NVARCHAR2 columns, though using these data types can substantially increase application complexities since various languages and libraries don't support NCHAR/ NVARCHAR2 columns or require you to jump through some hoops to use them. Your applications would also have to support both character sets, so your applications would all have to be Unicode enabled most likely, which is certainly possible but it may not be a trivial change.
Justin -
Chinese Characters in Discoverer Plus
Hi,
I am having the problem of outputting chinese characters in Discoverer Plus on the client browser. The chinese characters are represented by "box" when they are outputted to Discoverer plus. The chinese characters can be shown with the Report Builder. My database is running on UTF8 characterset.
I have done some configurations to output the chinese characters to the Report Builder. Besides, the chinese characters can be shown in the PDF reports generated from the Report Server. The configurations that I have done is to modify some of the files in ORACLE_HOME/bin/ and ORACLE_HOME/guicommon9/tk90/admin/.
How do I ouput the chinese characters in Discoverer Plus?
Thank you.
Cheers,
Joeyi have installed sqlplus and oracle db in the same PC under chinese win xp.
i found that if you spool the output to a text file, and type in dos-prompt, it still cannot display the chinese character properly. but if you open the text file by notepad, bingo, you can the chinese character.
i think that it is because dos-prompt application is non-unicode application. so it could not display unicode character properly.
as a result, if you want to display unicode character in non-unicode application (run sqlplus under dos-prompt), you have to set the NLS_LANG environment variable which match the character set of non-unicode application which your operating system assigned. in my case, it should be Big5. then oracle would do the conversion for you automatically, i.e. from unicode in DB to Big5 in client.
I either set the NLS_LANG environment variable in one of the 2 ways:
NLS_LANG=american_america.zht16big5 or
NLS_LANG=american_america.zht16hkscs
Regards,
KH -
Problem to insert Chinese Characters(GB3212) into MySQL
I met a problem to insert Chinese Characters (GB3212) into MySQL using Entity Bean (or JPA).
For example, when a hardcoded string "{color:#ff0000}电器me元件{color}" is inserted, it is displayed as "{color:#ff0000}??me??{color}" in MySQL.
The NamedQuery is also not working for Chinese Characters.
The setting are as following:
GlassFish JDBC connection pool: useUnicode=true, charecterEncoding=gb2312
NetBeans IDE: source encoding set to GB2312;
MySql table: the column set to CHARACTER SET gb2312;
Any experts, please give advice
Thanks lotI didn't noticed that there is a {color:#ff0000}sun-resources.xml{color} file under {color:#ff0000}<ejb project>/server resources{color}.
This file has a pool configuration. This config just overwite the paremeter i added using Admin Console every time a client is lauched. So there are two option to fix this problem.
1. Insert the follwowing two lines into the {color:#ff0000}sun-resources.xml{color}
<property name="characterEncoding" value="gb2312"/>
<property name="useUnicode" value="true"/>
2. delete the everthing in the {color:#ff0000}sun-resources.xml, using Admin Console {color}config your own pool & DataSource
I tried first option & it works. -
How to insert chinese characters in a table use FDK?
Hello~~
I am expecting to insert chinese characters in an XML file's table.
I'm using FDK7.2, if i use:
F_ApiAddText(docId, &tRange.beg, "asdf");
The English letters "asdf" can be insert correctly in the right place,
But, if insert chinese characters like this:
F_ApiAddText(docId, &tRange.beg, "人们");
No characters insert.
How can i solve this problem?
Please advise
Thanks
zhaopengZhaopeng,
Which encoding are you using for the Chinese characters? FrameMaker 7.2 does not support Unicode or UTF-8. I have not done this before, but I guess you need to supply the characters in Big5 resp. GBK encoding, see
http://help.adobe.com/en_US/FrameMaker/8.0/chinese_korean.pdf
[Ignore the 8.0 in the URL, the document talks about FrameMaker 7]
You also may have to make sure the paragraph format at your text location uses a Chinese font before inserting characters.
- Michael -
Insert more than 4000 characters using sql plus
I have a SQL script that creates a database. The problem is that some of the fields are longer than 4000 characters in the INSERT statement and Oracle doesn't seem to like it.
The field is a clob and works fine in the application (i.e. I can insert more than 4000 characters using the app) - how do I achieve this in a SQL script?
Any help is much appreciated.
Cheers,
SteveHi,
This pl/sql block works absolutely fine in SQL*Plus inserting > 4000 characters into clob column:
declare
l_str varchar2(8000);
l_str1 varchar2(2400) := 'first part of the verly long string...';
l_str2 varchar2(2400) := 'second part of the verly long string...';
begin
l_str := l_str1 || l_str2;
insert into tmpl values (l_str);
end;
So, you'll have to replace inserts with pl/sql blocks in your script.
Tested in Oracle 8.1.7.0.0
Regards,
Andrew Velitchko
BrainBench MVP for Developer/2000
http://www.brainbench.com -
hi
I have my Database with UTF-8 characterset.
I have sql file that contains data in chinese characters.
I need to run this sql and insert data into my database tables.
The sql file is simple text file saved in UTF-8 encoding.
Do I need to install chinese font on my machine to be able to run the sql successfully?
My nls_lang setting is AMERICAN_AMERICA.UTF8.
kelvinWhat is your operating system characterset? What is your database's operating system? What version of Oracle do you use?
-
To display chinese characters with SQL Developer
I have created one table on the Oracle Express Database. In this table ther is one field Nchar tipe.
The NLS_CHARACTERSET of the d.b. is WE8MSWIN1252, the NLS_NCHAR_CHARACTERSET is AL16UTF16.
I have done an insert on the table and in this field i have inserted this word: 了解更多
When i do a select comand with sql developer, on the results i see this only this •••• .
But if i copy this and cut on the Sql Developer editor, i see the corret word.
How could i configurate ?
Regards
MarioHi
The following works but there may be better solutions:
http://totierne.blogspot.com/2008/05/issuesquare-boxes-as-text-characters.html
Issue:Square boxes as text characters Solution:Add fonts
Chinese characters in Linux see Debian Chinese How To [1] basically:
1. create a jre/lib/fonts/fallback directory if necessary and
2. copy or link the fonts files into this directory. (On my Linux system: /usr/share/fonts/truetype/arphic/gbsn00lp.ttf )
-Turloch -
Unable to insert Chinese characters in Database
My problem is that I am not able to insert chinese
(to traditional chinese) characters into my tables in the
database.
I have changed the character set to UTF8 while creating the
database and also tried the alter session command in SQL to
alter the NLS_LANGUAGE and NLS_TERRITORY (to say traditional chinese).
But this did not solve my problem.
Also tried all possibilites like getting Chinese characters
in my notepad by copy - paste from a Chinese web site
but while giving the insert into command in my database
it takes some junk values.
Someone PLEASE HELP!!!URGENT!!!
Thanks in advance.
RKP
nullYou mentioned in your first note that you have set your database character set to UTF-8? If so, then you are able to store and retrieve multilingual data, including Chinese and Japanese characters. Your issue is not the database. Your client OS must be able to support these languages as well. It is likely that your version of OS supports only Latin and Western European characters. By the way changing your NT regional setting only effects sorting, date formats etc. It doesn't help you change the languages that your keyboard will support.
1.To determine your Win32 operating system's current ANSI CodePage (ACP). This can be found by bringing up the registry editor (Start --> Run..., type "regedit.exe", and click "OK") and looking at the
registry entry HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\ACP (there are many registry entries with very similar names, so please make sure that you are looking at the right place in the registry).
2.To find the character set in the table below based on the ACP you got above.
ANSI CodePage (ACP) Client character set (3rd part of NLS_LANG) (*1)
1250 EE8MSWIN1250
1251 CL8MSWIN1251
1252 WE8MSWIN1252
1253 EL8MSWIN1253
1254 TR8MSWIN1254
1255 IW8MSWIN1255
1256 AR8MSWIN1256
1257 BLT8MSWIN1257
1258 VN8MSWIN1258
874 TH8TISASCII
932 JA16SJIS
936 ZHS16GBK
949 KO16MSWIN949
950 ZHT16MSWIN950
others UTF8 (*2)
(*1) The character sets listed here are compatible with Win32's non-Unicode graphical user interface (GUI). Since Win32's MSDOS Box (Command Prompt) uses different character sets, NLS_LANG needs to be manually set in the MSDOS Box (or set in a batch script) in order to handle the difference
between Win32's GUI and MSDOS Box. (Please see "NLS_LANG Settings in MS-DOS Mode and Batch Mode" in the Oracle8i Installation Guide Release 2 (8.1.6) for Windows NT, part# A73010-01.)
(*2) If you use UTF8 for the 3rd part of NLS_LANG on Win32, client programs that you can use on this operating system would be limited to the ones that explicitly support this configuration. Recent versions of Oracle Forms' Client/Server mode (Fat-Client) on NT4.0 would be an example of such client
programs. This is because the user interface of Win32 is not UTF8, therefore the client programs have to perform explicit conversions between UTF8 (used in Oracle side) and UTF16 (used in Win32 side). -
Inserting Special Character using SQL*Plus
I am trying to insert special character like ® using SQL*Plus but it is inserting a .(dot) instead.
Environment:
Oracle Enterprise version : 9.2.0.3.0
Sun Solaris 8
Any help will be appreciated.
Regards,
NirmalyaThat's the reason I use ASCII values always for special characters.
SQL> create table sample1(col1 varchar2(50))
2 /
Table created.
SQL> insert into sample1
2 select 'The temperature outside is 20'||chr(176)||' centigrade' col1
3 from dual
4 /
1 row created.
SQL> commit
2 /
Commit complete.
SQL> select * from sample1
2 /
COL1
The temperature outside is 20° centigrade
1 row selected.
SQL> drop table sample1 purge
2 /
Table dropped.
SQL> Cheers
Sarma. -
Inserting Japanese characters to SQL Server via CFMX
What is necessary in the setup to save non-Latin characters
to SQL Server via CFMX form? The ColdFusion data source has the
Unicode option enabled (Enable Unicode for data sources configured
for non-Latin characters). The target field in the database is an
nvarchar. What else is necessary to properly insert and then later
display the non-Latin characters?
On Microsoft's site they describe the need to convert to and
from UCS-2 when accessing SQL Server via ASP. Is this type of
conversion relevant to CFMX?jegrubbs wrote:
> What is necessary in the setup to save non-Latin
characters to SQL Server via
> CFMX form? The ColdFusion data source has the Unicode
option enabled (Enable
> Unicode for data sources configured for non-Latin
characters). The target field
> in the database is an nvarchar. What else is necessary
to properly insert and
> then later display the non-Latin characters?
- define db columns as "N" types
- ensure cf pages are utf-8 encoding:
--tag the files w/a BOM
--use
<cfprocessingDirective pageencoding="utf-8">
on each page
--use
<cfset setEncoding("form","utf-8")>
<cfcontent type="text/html; charset=utf-8">
in application.cfm or .cfc
- when doing INSERT/UPDATE make sure to use either unicode
hinting (N'text') or
cfqueryparam (making sure to turn on the unicode option for
that DSN in
cfadmin). cfqueryparam is the best choice.
also see:
http://www.sustainablegis.com/unicode/greekTest.cfm
> On Microsoft's site they describe the need to convert to
and from UCS-2 when
> accessing SQL Server via ASP. Is this type of conversion
relevant to CFMX?
nope the JDBC driver will handle that gruff. make sure you
use the JDBC driver
(name as ms sql server in cfadmin) and NOT the odbc bridge
thnig.
Maybe you are looking for
-
Error while inserting spatial data
Hi All, I have a problem while inserting spatial data. could some one please help me in solving this. I have creatd a table with spatial index. INSERT INTO USER_SDO_GEOM_METADATA VALUES('SDO_CA_test', 'CA', SDO_DIM_ARRAY(
-
How can we maintain tetxs in webdynpro insted of hardcode
Hi Experts, i am new for this webdynpro abap.how can we maintain tetxs in webdynpro insted of hardcode like text symbols in abap.we are using freaquently texts in message manager.in best practice we should not maintain hard code. guys
-
Controlling sound file with play, stop and mute button in AS3.0?
the method for stopping/playing sound in 2.0 don't work for 3.0. i can stop the sound by going to a different page/frame on the site. but i want the buttons. 1. play button? 2.stop button? 3.mute button? thanks in advance!
-
Workflow in 'Revised and Saved' status
Hi Friends, I am trying to activate a workflow in Dev system. After I click on activate button the workflow gets into 'revised and saved' status. Business object is in active stage. This is happening since last couple of days, earlier to that I was a
-
Plume illustrator besoin d'aide
Bonjour a tous, Tentant d'en apprendre toujours plus sur Illustrator, j'ai affaire a un petit problème donc je vous expliques, Musketon un artiste que j'aime beaucoup a realisé un tutoriel lien ci dessous : http://musketon.com/from-sketch-to-vector/