Chinaunix首页 | 论坛 | 博客
  • 博客访问: 537085
  • 博文数量: 154
  • 博客积分: 4055
  • 博客等级: 上校
  • 技术积分: 1381
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-01 14:26
文章分类

全部博文(154)

文章存档

2014年(2)

2013年(2)

2011年(2)

2010年(11)

2009年(9)

2008年(35)

2007年(22)

2006年(71)

我的朋友

分类: Oracle

2007-01-07 10:25:30

If the database has been created with the wrong character set, use the following to change the character set
UPDATE SYS.PROPS$
SET VALUES$ = 'WE8ISO8859P1'
WHERE NAME = 'NLS_CHARACTERSET';
It is VERY important to specify the character set name correctly. If the NLS_CHARACTERSET is updated to an invalid value, it will not then be possible to restart the database once it has been shutdown.
Update
From version 8 you can now update the character set using the alter database command. An extract from the documentation is included below, the basic rule being that the new characterset must be a superset of the current set. Interestingly enough, I tried the above update with a characterset that violated that rule, it still works - of course, any character code differences will would inevitably cause some problems, so it would be safest to use the supported syntax.
Quote from the (8.1.6) documentation reveals:


"Changing the Character Set After Database Creation
In some cases, you may wish to change the existing database character set. For instance, you may find that the number of languages that need to be supported in your database have increased. In most cases, you will need to do a full export/import to properly convert all data to the new character set. However, if and only if, the new character set is a strict superset of the current character set, it is possible to use the ALTER DATABASE CHARACTER SET to expedite the change in the database character set.
The target character set is a strict superset if and only if each and every codepoint in the source character set is available in the target character set, with the same corresponding codepoint value. For instance the following migration scenarios can take advantage of the ALTER DATABASE CHARACTER SET command since US7ASCII is a strict subset of WE8ISO8859P1, AL24UTFFSS, and UTF8:
Current Character Set New Character Set New Character Set is strict superset?
US7ASCII WE8ISO8859P1 yes
US7ASCII ALT24UTFFSS yes
US7ASCII UTF8 yes

WARNING: Attempting to change the database character set to a character set that is not a strict superset can result in data loss and data corruption. To ensure data integrity, whenever migrating to a new character set that is not a strict superset, you must use export/import. It is essential to do a full backup of the database before using the ALTER DATABASE [NATIONAL] CHARACTER SET statement, since the command cannot be rolled back. The syntax is:
ALTER DATABASE [] CHARACTER SET ;
ALTER DATABASE [] NATIONAL CHARACTER SET ;

The database name is optional. The character set name should be specified without quotes, for example:
ALTER DATABASE CHARACTER SET WE8ISO8859P1;

To change the database character set, perform the following steps. Not all of them are absolutely necessary, but they are highly recommended:
SQL> SHUTDOWN IMMEDIATE; -- or NORMAL

SQL> STARTUP MOUNT;
SQL> ALTER SYSTEM ENABLE RESTRICED SESSION;
SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
SQL> ALTER DATABASE OPEN;
SQL> ALTER DATABASE CHARACTER SET ;
SQL> SHUTDOWN IMMEDIATE; -- or NORMAL
SQL> STARTUP;

To change the national character set, replace the ALTER DATABASE CHARACTER SET statement with ALTER DATABASE NATIONAL CHARACTER SET. You can issue both commands together if desired."

阅读(993) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~