ehxz 发表于 2006-12-28 16:05:14

oracle9204更改字符集步骤方法

<p>oracle9204更改字符集步骤方法(WE8ISO8859P1->ZHS16GBK):<br />由于我们经常做不同数据库的导出导入时遇到的服务器的字符集不同,导致我们原有的无法正常导入工作,<br />这时需要我们做数据库字符集的更改工作,<br />字符集是在安装数据库时选定的,一旦数据库创建之后,数据库的字符集是不能改变的,如果要改变数据库的字符集, 只有重新创建数据库。<br />但通常也可以在特定的条件下通过一些其他途径来完成字符集的转换(这里强烈建议创建数据库时就要考虑好字符集)<br />单字节=>单字节<br />多字节=>多字节<br />且是子集到超集时,可以用alter database CHARACTER set 新的字符集;<br />通常对于单字节向多字节转换和非子集到超集转换时采用exp/imp+internal_use的方法<br />这里只介绍WE8ISO8859P1->ZHS16GBK的步骤方法:</p><p>检查当前的字符集为WE8ISO8859P1:<br />SQL> set wrap off<br />SQL> select * from v$nls_parameters;</p><p>PARAMETER VALUE<br />---------------------------------------------------------------- ---------------<br />NLS_LANGUAGE AMERICAN<br />NLS_TERRITORY AMERICA<br />NLS_CURRENCY $<br />NLS_ISO_CURRENCY AMERICA<br />NLS_NUMERIC_CHARACTERS &#46;,<br />NLS_CALENDAR GREGORIAN<br />NLS_DATE_FORMAT DD-MON-RR<br />NLS_DATE_LANGUAGE AMERICAN<br />NLS_CHARACTERSET WE8ISO8859P1<br />NLS_SORT BINARY<br />NLS_TIME_FORMAT HH&#46;MI&#46;SSXFF AM</p><p>PARAMETER VALUE<br />---------------------------------------------------------------- ---------------<br />NLS_TIMESTAMP_FORMAT DD-MON-RR HH&#46;MI<br />NLS_TIME_TZ_FORMAT HH&#46;MI&#46;SSXFF AM<br />NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH&#46;MI<br />NLS_DUAL_CURRENCY $<br />NLS_NCHAR_CHARACTERSET UTF8<br />NLS_COMP BINARY<br />NLS_LENGTH_SEMANTICS BYTE<br />NLS_NCHAR_CONV_EXCP FALSE</p><p>19 rows selected&#46;</p><p>SQL></p><p>将数据库启动到RESTRICTED模式下做字符集更改:<br />SQL> conn /as sysdba<br />Connected&#46;<br />SQL> shutdown immediate;<br />Database closed&#46;<br />Database dismounted&#46;<br />ORACLE instance shut down&#46;<br />SQL> startup mount<br />ORACLE instance started&#46;</p><p>Total System Global Area 236000356 bytes<br />Fixed Size 451684 bytes<br />Variable Size 201326592 bytes<br />Database Buffers 33554432 bytes<br />Redo Buffers 667648 bytes<br />Database mounted&#46;<br />SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;</p><p>System altered&#46;</p><p>SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;</p><p>System altered&#46;</p><p>SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0;</p><p>System altered&#46;</p><p>SQL> alter database open;<br /><br />Database altered&#46;</p><p>SQL> ALTER DATABASE CHARACTER SET ZHS16GBK;<br />ALTER DATABASE CHARACTER SET ZHS16GBK<br />*<br />ERROR at line 1:<br />ORA-12712: new character set must be a superset of old character set</p><p><br />提示我们的字符集:新字符集必须为旧字符集的超集,这时我们可以跳过超集的检查做更改:</p><p>SQL> ALTER DATABASE character set INTERNAL_USE ZHS16GBK;</p><p>Database altered&#46;</p><p>SQL> select * from v$nls_parameters;</p><p>PARAMETER VALUE<br />---------------------------------------------------------------- ---------------<br />NLS_LANGUAGE AMERICAN<br />NLS_TERRITORY AMERICA<br />NLS_CURRENCY $<br />NLS_ISO_CURRENCY AMERICA<br />NLS_NUMERIC_CHARACTERS &#46;,<br />NLS_CALENDAR GREGORIAN<br />NLS_DATE_FORMAT DD-MON-RR<br />NLS_DATE_LANGUAGE AMERICAN<br />NLS_CHARACTERSET ZHS16GBK<br />NLS_SORT BINARY<br />NLS_TIME_FORMAT HH&#46;MI&#46;SSXFF AM</p><p>PARAMETER VALUE<br />---------------------------------------------------------------- ---------------<br />NLS_TIMESTAMP_FORMAT DD-MON-RR HH&#46;MI<br />NLS_TIME_TZ_FORMAT HH&#46;MI&#46;SSXFF AM<br />NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH&#46;MI<br />NLS_DUAL_CURRENCY $<br />NLS_NCHAR_CHARACTERSET UTF8<br />NLS_COMP BINARY<br />NLS_LENGTH_SEMANTICS BYTE<br />NLS_NCHAR_CONV_EXCP FALSE</p><p>19 rows selected&#46;</p><p><br />重启检查是否更改完成:</p><p>SQL> shutdown immediate;<br />Database closed&#46;<br />Database dismounted&#46;<br />ORACLE instance shut down&#46;<br />SQL> startup<br />ORACLE instance started&#46;</p><p>Total System Global Area 236000356 bytes<br />Fixed Size 451684 bytes<br />Variable Size 201326592 bytes<br />Database Buffers 33554432 bytes<br />Redo Buffers 667648 bytes<br />Database mounted&#46;<br />Database opened&#46;<br />SQL> select * from v$nls_parameters;</p><p>PARAMETER VALUE<br />---------------------------------------------------------------- ---------------<br />NLS_LANGUAGE AMERICAN<br />NLS_TERRITORY AMERICA<br />NLS_CURRENCY $<br />NLS_ISO_CURRENCY AMERICA<br />NLS_NUMERIC_CHARACTERS &#46;,<br />NLS_CALENDAR GREGORIAN<br />NLS_DATE_FORMAT DD-MON-RR<br />NLS_DATE_LANGUAGE AMERICAN<br />NLS_CHARACTERSET ZHS16GBK<br />NLS_SORT BINARY<br />NLS_TIME_FORMAT HH&#46;MI&#46;SSXFF AM</p><p>PARAMETER VALUE<br />---------------------------------------------------------------- ---------------<br />NLS_TIMESTAMP_FORMAT DD-MON-RR HH&#46;MI<br />NLS_TIME_TZ_FORMAT HH&#46;MI&#46;SSXFF AM<br />NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH&#46;MI<br />NLS_DUAL_CURRENCY $<br />NLS_NCHAR_CHARACTERSET UTF8<br />NLS_COMP BINARY<br />NLS_LENGTH_SEMANTICS BYTE<br />NLS_NCHAR_CONV_EXCP FALSE</p><p>19 rows selected&#46;</p><p>SQL></p>
页: [1]
查看完整版本: oracle9204更改字符集步骤方法