SQL ALTER 语句:为什么使用 VARCHAR2(50 BYTE) 而不是 VARCHAR2(50 CHAR)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15136280/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 13:57:32  来源:igfitidea点击:

ALTER statement: Why VARCHAR2(50 BYTE) instead of VARCHAR2(50 CHAR)?

sqloraclecharacter-encodingoracle11g

提问by Withheld

I executed the following (Oracle 11g) SQL statement to increasean existing column's length from VARCHAR2(20 CHAR) to VARCHAR2(50 CHAR):

我执行下面(的Oracle 11g)的SQL语句,以增加从VARCHAR2(20 CHAR)到VARCHAR2(50 CHAR)现有列的长度:

ALTER TABLE USERX.MY_TABLE MODIFY (LASTNAME VARCHAR2(50));

It succeeded without incident, but when I look at the new Data Typecolumn, I see: VARCHAR2(50 BYTE)instead of VARCHAR2(50 CHAR).

它成功了,没有发生任何意外,但是当我查看新Data Type列时,我看到:VARCHAR2(50 BYTE)而不是VARCHAR2(50 CHAR).

My questions are:

我的问题是:

  1. Why BYTEand not CHAR? What have I done incorrectly?
  2. How do I fix the column's length to be VARCHAR2(100 CHAR)?
  1. 为什么是BYTE而不是 CHAR?我做错了什么?
  2. 如何将列的长度固定为VARCHAR2(100 CHAR)

回答by Withheld

Answering myself (thanks to the tip provided by this other answer):

回答我自己(感谢其他答案提供的提示):

I should have executed instead:

我应该执行:

ALTER TABLE USERX.MY_TABLE MODIFY (LASTNAME VARCHAR2(50 CHAR));

(note the extra CHARafter 50)

(注意CHAR50后的额外)