更改表中包含数据的列的大小 [英] alter the size of column in table containing data

查看:65
本文介绍了更改表中包含数据的列的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何在Oracle中缩短varchar2字段?

Possible Duplicate:
How to make a varchar2 field shorter in Oracle?

在Oracle(9i及更高版本)中

In Oracle(9i and above)

 Alter table employee  
 MODIFY ename varchar2(10);

我想将表employee的列ename从varchar2(30)更改为varchar2(10)

I want to alter the column ename of table employee from varchar2(30) to varchar2(10)

  • Case1:如果表中的数据具有包含长度小于10个字符的值的ename列(我的意思是它可以舒适地适合varchar2(10))-oracle允许吗?

  • 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 ?

情况2:如果表中的数据具有包含长度大于10个字符的值的ename列(我的意思是它不能容纳在varchar2(10)中)-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:是的,这很好.

Case 1 : Yes, this works fine.

情况2:这将失败,并显示错误ORA-01441:由于某些值太大而无法减小列长.

Case 2 : This will fail with the error ORA-01441 : cannot decrease column length because some value is too big.

分享并享受.

这篇关于更改表中包含数据的列的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆