php Oracle 存储单个字符时使用多少字节?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2850807/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How many bytes does Oracle use when storing a single character?
提问by mr-sk
I tried to look here:
我试着看这里:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#i3253
http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#i3253
And I understand that I have to provide string length for the column, I'm just not able to find out how many bytes oracle uses when storing a character. My limit is 500 characters, so if its 1 byte / character, I can create the column with 500, if its 2 byte / character then 1000, etc.
而且我知道我必须为列提供字符串长度,我只是无法找出 oracle 在存储字符时使用了多少字节。我的限制是 500 个字符,所以如果它是 1 个字节/字符,我可以用 500 创建列,如果它是 2 个字节/字符,那么 1000,等等。
Anyone have a link to the documentation or know for certain?
任何人都有文档的链接或确切知道?
In case it matters, the SQL is being called from PHP, so these are PHP strings I'm inserting into the database. Thanks.
如果重要,SQL 是从 PHP 调用的,所以这些是我插入到数据库中的 PHP 字符串。谢谢。
回答by Vincent Malgrat
the number of bytes needed to store a character will depend upon the character set. If you want to store 500 characters and don't know the character set of the target database you should create the column (or variable) as a VARCHAR2(500 CHAR) or CHAR(500 CHAR).
存储字符所需的字节数取决于字符集。如果要存储 500 个字符并且不知道目标数据库的字符集,则应将列(或变量)创建为 VARCHAR2(500 CHAR) 或 CHAR(500 CHAR)。
回答by Vadim K.
A plain CHARis not necessarily one byte, depending on the setting of NLS_LENGTH_SEMANTICS.
一个普通CHAR的不一定是一个字节,这取决于NLS_LENGTH_SEMANTICS.
See Oracle's SQL Language Referenceas a starting point. If you need to dig deeper, have a look at Oracle's Globalization Support Guide.
回答by Neil Knight
A single CHAR will take 1 byte.
单个 CHAR 将占用 1 个字节。
Try here:
在这里尝试:

