SQL 更改包含数据的表中列的大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10179217/
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
alter the size of column in table containing data
提问by Learner
Possible Duplicate:
How to make a varchar2 field shorter in Oracle?
In Oracle(9i and above)
在 Oracle(9i 及以上)中
Alter table employee
MODIFY ename varchar2(10);
I want to alter the column ename of table employee from varchar2(30) to varchar2(10)
我想将表员工的列名从 varchar2(30) 更改为 varchar2(10)
Case1 : if the table has data having ename column containing values which are of length less than 10 char(i mean it can fit in varchar2(10) comfortably) - is this allowed by oracle ?
Case 2: if the table has data having ename column containing values which are of length greater than 10 char(i mean it can not fit in varchar2(10)) - is this not allowed by oracle ?
案例 1:如果表中的数据具有 ename 列,其中包含长度小于 10 个字符的值(我的意思是它可以轻松地放入 varchar2(10) 中)- oracle 允许这样做吗?
情况 2:如果表中的数据具有 ename 列,其中包含长度大于 10 个字符的值(我的意思是它不能放入 varchar2(10)) - 这是否被 oracle 允许?
采纳答案by Bob Jarvis - Reinstate Monica
Case 1 : Yes, this works fine.
案例 1:是的,这很好用。
Case 2 : This will fail with the error ORA-01441 : cannot decrease column length because some value is too big.
情况 2:这将失败并显示错误 ORA-01441:无法减少列长度,因为某些值太大。
Share and enjoy.
分享和享受。