How to reduce the column length (CHAR) ? [split topic TG] [message #438959] |
Wed, 13 January 2010 03:55  |
janmichael
Messages: 1 Registered: January 2010
|
Junior Member |
|
|
I hope someone can help me
I like to decrease a column from 15 to 10
-- this is working
create table t ( col varchar2(14) ) ; -- create table
insert into t values ('12345678901234' ); -- insert data
alter table t modify col varchar2(10) ; -- not working jet
update t set col = substr(col,1,10); -- decrease data
select * from t; -- show the short data
alter table t modify col varchar2(10); -- working
-- but here it comes
create table c ( col char(15) ) ; -- create table - now with char (not varchar2 )
insert into c values ('123456789012345' ); -- insert data
alter table c modify col char(10) ; -- not working
update c set col = substr(col,1,10); -- decrease data
alter table c modify col char(10); -- and this is not working !!!!!!!!!!!!!!!!!!!
Why can i decrease a varchar but not a char ???
What can i do ?
(i am working with oracle 9 )
|
|
|
|
Re: How to reduce the column length (CHAR) ? [split topic TG] [message #438985 is a reply to message #438959] |
Wed, 13 January 2010 07:01   |
cookiemonster
Messages: 13964 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
You can do it with just chars:
create table c ( col char(15) ) ;
insert into c values ('123456789012345' ); -- insert data
alter table c add col2 char(10) ; -- add new column
update c set col2 = substr(col,1,10); -- copy data to new column
alter table c drop col; -- lose orignal column
alter table c add col char(10); -- re-add column with new size
update c set col = col2; -- copy data back
alter table c drop col2; --lose original column
That said, this is one example of the many reasons why char columns are a colossal pain to work with. If you can change them to varhcar2, do so.
|
|
|
|
|
|
|
|
|
Re: How to reduce the column length (CHAR) ? [split topic TG] [message #439157 is a reply to message #438959] |
Thu, 14 January 2010 12:36   |
Its_me_ved
Messages: 979 Registered: October 2009 Location: India
|
Senior Member |
|
|
Quote:
should be "If it was I" not I were I...
sorry,did not know that poeple over here now concentrating on english more than technical things!!! aaah.... it was a typo! but its funny to see the reaction of so many people in a technical forum like this? isn't it?? ...and still a sane individual with good understanding can understand what my reply was!!!!! I think I did not found one here!!!
hmmm..."sab pagal hain!!!" (all are mad!) was really a good suitable remark by a newbie on this forum...
yeah, i candid it was wrong while writing the statement but did not know people of your class would react more on some stupid stuff...
My advice you should also re read the forum guidelines once again!!!!!may be you are missing something or to lazy to read them.WHY SHOULD NOT YOU?
And ya, most of the time its being observed that ORAFAQ become more a forum to comment on stupid stuff deviating from original topic.
[Updated on: Thu, 14 January 2010 13:18] Report message to a moderator
|
|
|
|
Re: How to reduce the column length (CHAR) ? [split topic TG] [message #439162 is a reply to message #439161] |
Thu, 14 January 2010 13:23   |
Its_me_ved
Messages: 979 Registered: October 2009 Location: India
|
Senior Member |
|
|
If you want to make joke , then I believe this is not the good place here..there is community hangout/General forum.
I would suggest make fun as much as you can...by posting link or whatever...
But doing such stuff just only deviates from the original question.It degrades the quality of solutions you people provide!! Hope the message I conveyed is clear here!!!
Regards,
Ved
|
|
|
|
|
|
|
Re: How to reduce the column length (CHAR) ? [split topic TG] [message #439170 is a reply to message #439169] |
Thu, 14 January 2010 14:40   |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
Quote:Oh yeah, can see some more people here....
No idea what you are attempting to say there.
Quote:this is your third post here..dont the same thing apply to you as well? What same thing? That I'm taking excessive ffence to a little bit of fun? No, I wouldn't say so.
Quote:people of your class And what class would that be?
Anyway, I find your ranting tiresome. goodbye.
|
|
|
|