oracleÖÐÎÄÂÒÂë½â¾öÒªÁì
oracle ÖÐÎÄÂÒÂëͨ³£ÓÉ×Ö·û¼¯¹ýʧÒýÆð¡£½â¾ö°ì·¨ÈçÏ£º¼ì²éÊý¾Ý¿â×Ö·û¼¯£¬Ó¦Îª utf8¡£ÐÞ¸Ä×Ö·û¼¯Îª utf8¡£¼ì²é¿Í»§¶Ë×Ö·û¼¯£¬Ó¦ÓëÊý¾Ý¿âÒ»Ö¡£ÑéÖ¤×Ö·û¼¯ÒѸü¸Ä¡£ÖØмÓÔØÊý¾Ý£¬Ö¸¶¨×Ö·û¼¯Îª utf8¡£
½â¾ö Oracle ÖÐÎÄÂÒÂë
Oracle Êý¾Ý¿âÖÐÎÄÂÒÂëÊÇÒ»¸ö³£¼ûµÄ¹ýʧ£¬¿ÉÄÜÊÇÓÉÓÚ×Ö·û¼¯ÉèÖò»×¼È·Ôì³ÉµÄ¡£ÒÔÏÂÊǽâ¾ö¸ÃÎÊÌâµÄ°ì·¨£º
1. ¼ì²é×Ö·û¼¯ÉèÖÃ
ÔÚÊý¾Ý¿âÖУ¬Ö´ÐÐÒÔÏÂÏÂÁîÒÔÉó²éÄ¿½ñ×Ö·û¼¯£º
SELECT * FROM V$NLS_PARAMETERS WHERE PARAMETER = 'NLS_CHARACTERSET';
µÇ¼ºó¸´ÖÆ
Êä³öÓ¦ÀàËÆÓÚ£º
PARAMETER VALUE ---------------------- ------------------------ NLS_CHARACTERSET UTF8
µÇ¼ºó¸´ÖÆ
ÈôÊÇ×Ö·û¼¯²»ÊÇ UTF8£¬ÔòÐèÒª¶ÔÆä¾ÙÐиü¸Ä¡£
2. ¸ü¸Ä×Ö·û¼¯
Òª¸ü¸Ä×Ö·û¼¯£¬ÇëÖ´ÐÐÒÔÏÂÓï¾ä£º
ALTER SYSTEM SET NLS_CHARACTERSET = 'UTF8';
µÇ¼ºó¸´ÖÆ
È»ºó£¬ÖØÐÂÆô¶¯Êý¾Ý¿âÒÔʹ¸ü¸ÄÉúЧ£º
SHUTDOWN IMMEDIATE; STARTUP;
µÇ¼ºó¸´ÖÆ
3. ¼ì²é¿Í»§¶Ë×Ö·û¼¯
Êý¾Ý¿â¿Í»§¶ËÒ²ÐèҪʹÓÃÓëÊý¾Ý¿âÏàͬµÄ×Ö·û¼¯¡£ÔÚ Java ¿Í»§¶ËÖУ¬¿ÉÒÔʹÓÃÒÔÏ´úÂ룺
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "user", "password"); Statement stmt = connection.createStatement(); stmt.execute("SET NLS_CHARACTERSET = UTF8");
µÇ¼ºó¸´ÖÆ
4. ÑéÖ¤×Ö·û¼¯
ÔÙ´ÎÖ´Ðа취 1 ÖеÄÅÌÎÊÒÔÑéÖ¤×Ö·û¼¯ÊÇ·ñÒѸü¸ÄΪ UTF8¡£
5. ÖØмÓÔØÊý¾Ý
ÈôÊÇÊý¾ÝÊÇÔÚʹÓþÉ×Ö·û¼¯Ê±¼ÓÔصģ¬ÔòÐèÒª½«ÆäÖØмÓÔØ¡£Ê¹ÓÃÒÔÏÂÏÂÁî´ÓÎļþÖмÓÔØÊý¾Ý£º
LOAD DATA INFILE 'datafile.csv' INTO TABLE users FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' IGNORE 1 LINES (name VARCHAR(255) CHARACTER SET UTF8);
µÇ¼ºó¸´ÖÆ
Ö´ÐÐÕâЩ°ì·¨ºó£¬Oracle ÖеÄÖÐÎÄÂÒÂëÓ¦»ñµÃ½â¾ö¡£
ÒÔÉϾÍÊÇoracleÖÐÎÄÂÒÂë½â¾öÒªÁìµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡