Solved

Need help on Oracle sql

Posted on 2014-10-11
3
483 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

734 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