Solved

Need help on Oracle sql

Posted on 2014-10-11
3
457 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
3 Comments
 
LVL 20

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 76

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now