CHAR和NCHAR字符类型之间的区别?

Rake 2002-09-18 12:39:02
NCHAR Same as CHAR, stores National Language Support (NLS) character data.
这么一句话,什么意思呢?
从PL/SQL程序设计一书中找到如下解释:
NLS字符类型用来存储来自不同于PL/SQL语言的字符集中的字符串。这个字符集就是国家字符集。

这下好了,看得我云里雾里,还是不明不白。 NLS character data到底是什么?难道还有普通character data?

而且向这些字段插入数据的时候会出错:
ORA-12704: character set mismatch

请教大家!
...全文
215 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
bzszp 2002-09-18
  • 打赏
  • 举报
回复
char(n) n=1 to 2000字节 定长字符串,n字节长,如果不指定长度,缺省为1个字节长(一个汉字为2字节)
varchar2(n) n=1 to 4000字节 可变长的字符串,具体定义时指明最大长度n,
这种数据类型可以放数字、字母以及ASCII码字符集(或者EBCDIC等数据库系统接受的字符集标准)中的所有符号。
如果数据长度没有达到最大值n,Oracle 8i会根据数据大小自动调节字段长度,
如果你的数据前后有空格,Oracle 8i会自动将其删去。VARCHAR2是最常用的数据类型。
Rake 2002-09-18
  • 打赏
  • 举报
回复
同样的问题,我在itpub上得到的回答,大家参考一下。只是看不太明白。

The CREATE DATABASE statement has the CHARACTER SET clause and the
additional optional clause NATIONAL CHARACTER SET to declare the character set
to be used as the database character set and the national character set.

Because the database character set is used to identify and to hold SQL and PL/SQL
source code, it must have either EBCDIC or 7-bit ASCII as a subset, whichever is
native to the platform. Therefore, it is not possible to use a fixed-width, multibyte
character set as the database character set, only as the national character set.
luckysxn 2002-09-18
  • 打赏
  • 举报
回复
up,up
bzszp 2002-09-18
  • 打赏
  • 举报
回复
NCHAR、NVARCHAR2,国家字符集,与环境变量NLS指定的语言集密切相关,使用方法和CHAR、VARCHAR2相同。
Rake 2002-09-18
  • 打赏
  • 举报
回复
SongZip: 能谈谈nchar和nvarchar吗?

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧