Resize a column in a table containing data

Possible duplicate:
How to make varchar2 field shorter in Oracle?

In Oracle (9i and above)

Alter table employee MODIFY ename varchar2(10); 

I want to change the table employee column name from varchar2 (30) to varchar2 (10)

  • Case1: if there is data in the table that has an ename column whose length is less than 10 char (I mean that it can comfortably fit in varchar2 (10)) - is this allowed by the oracle?

  • Case 2: if there is data in the table containing an ename column that is longer than 10 char (I mean that it cannot fit in varchar2 (10)) - is this not allowed by the oracle?

+47
sql oracle
Apr 16 '12 at 18:01
source share
1 answer

Case 1: Yes, it works great.

Case 2: Error with error ORA-01441: cannot reduce the column length because some value is too large.

Share and enjoy.

+42
Apr 16 '12 at 18:17
source share



All Articles