Difference between BYTE and CHAR in column datatypes(列数据类型中 BYTE 和 CHAR 之间的区别)
问题描述
在Oracle中,有什么区别:
In Oracle, what is the difference between :
CREATE TABLE CLIENT
(
NAME VARCHAR2(11 BYTE),
ID_CLIENT NUMBER
)
和
CREATE TABLE CLIENT
(
NAME VARCHAR2(11 CHAR), -- or even VARCHAR2(11)
ID_CLIENT NUMBER
)
推荐答案
让我们假设数据库字符集是 UTF-8,这是 Oracle 最新版本中推荐的设置.在这种情况下,某些字符需要超过 1 个字节才能存储在数据库中.
Let us assume the database character set is UTF-8, which is the recommended setting in recent versions of Oracle. In this case, some characters take more than 1 byte to store in the database.
如果将字段定义为 VARCHAR2(11 BYTE)
,Oracle 最多可以使用 11 个字节进行存储,但实际上您可能无法在该字段中存储 11 个字符,因为某些它们需要一个以上的字节来存储,例如非英文字符.
If you define the field as VARCHAR2(11 BYTE)
, Oracle can use up to 11 bytes for storage, but you may not actually be able to store 11 characters in the field, because some of them take more than one byte to store, e.g. non-English characters.
通过将字段定义为 VARCHAR2(11 CHAR)
,您告诉 Oracle 它可以使用足够的空间来存储 11 个字符,无论存储每个字符需要多少字节.单个字符最多可能需要 4 个字节.
By defining the field as VARCHAR2(11 CHAR)
you tell Oracle it can use enough space to store 11 characters, no matter how many bytes it takes to store each one. A single character may require up to 4 bytes.
这篇关于列数据类型中 BYTE 和 CHAR 之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:列数据类型中 BYTE 和 CHAR 之间的区别


基础教程推荐
- oracle区分大小写的原因? 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 在多列上分布任意行 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01