Solved

Need help on Oracle sql

Posted on 2014-10-11
3
492 Views
Last Modified: 2014-10-14
Hi ,

I have table called my_Comments , which has an column called comments which is CLOB. I  have to change the CLOB column to VARCHAR2 , Iam following the below approach to keep the column position , Below is the error Iam getting. Any help is really appreciated.

The table is stored in USER_TAB tablespace and the CLOB is stored in USER_LOB tablespace.  As of now the column comments data is stored in USER_LOB tablespace.  After changing it to VARCHAR2 , I need to move it from USER_LOB to USER_TAB tablespace.


Table Structure:

MY_COMMENTS  -- Stored in USER_TAB tablespace.
 
ID NUMBER,
TITLE VARCHAR2(4000 CHAR),
COMMENTS CLOB --> Stored in USER_LOB tablespace.
CREATED_BY NUMBER




alter table my_comments add c2 varchar2(4000);
update my_comments set c2 = DBMS_LOB.SUBSTR(comments,1,4000);
update my_comments set comments = null;
commit;
alter table my_comments modify COMMENTS LONG;
alter table t modify c clob;
update t set c = c2;
alter table t drop column c2;
commit;


Error starting at line 9 in command:
alter table my_comments modify COMMENTS LONG
Error report:
SQL Error: ORA-22859: invalid modification of columns
22859. 00000 -  "invalid modification of columns"
*Cause:    An attempt was made to modify an object, REF, VARRAY, nested
           table, or LOB column type.
*Action:   Create a new column of the desired type and copy the current
           column data to the new type using the appropriate type
           constructor.


Any help is really appreciated.
0
Comment
Question by:sam_2012
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 21

Expert Comment

by:Amitkumar Panchal
ID: 40375859
As far as I know LONG has been depricated since 8i and not recommended by oracle.

Why dont you use select..as.. and create a new table with varchar2 and then recreate every constraints, indexes and other DB objects associated with the older one. I know its difficult on when we have huge data as well as many tables. But its worth to give it a try.

Another one just add new column of varchar2, copy clob data to new column and drop the clob. But this one will change the column position which you dont want to do.
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40376108
Error seem self-explanatory:  you cannot modify the CLOB column.

I think we have covered the alternative ways to do this in your previous questions that are pretty much the same question as this.

You can keep trying ways to get around it but I feel the answer will always be the same.

Just like the last questions:  dbms_redefinition is probably the way to go with the requirements you have.
0
 

Author Comment

by:sam_2012
ID: 40381373
thanks . I have used DBMS_REDEFINITION for changing the column .
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to recover a database from a user managed backup
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question