Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: How can I modify (decrease) a column ?
The reason that it won't let you is because it is just doing the easy thing and saying I won't make it smaller unless it's empty.
create a table with the following if you aren't using 8i.
create table temp_table as select pk,column_I_want_to_change from my table;
update the table you want to change and set all rows to null (column_I_want_to_change ).
change the field.
Use the temp table to update the values back.
drop the temp table.
-- Robert Fazio, Oracle DBA rfazio_at_home.com remove nospam from reply address http://24.8.218.197/ "Peter Wichert" <peter.wichert_at_gis.dew.de> wrote in message news:8gl625$9qi$1_at_gdv106.gis.dew.de...Received on Fri May 26 2000 - 00:00:00 CDT
> Hi,
>
> I'm trying to change the layout of a table. I just want to change a
CHAR(10)
> to CHAR(8), and ORACLE tells me to clear (empty) the table first. But I
> don't have records with longer entries than 8 chars, so why must I delete
my
> records?
>
> It says:
>
> "column to be modified must be empty to decrease column length"
>
> Generally spoken, is there a solution to savely change my database layout
> (shure, "compatible" changes only) without loosing my data (if I know what
> i'm doing :-)) ?
>
> Thanks for any help,
> Peter
>