Solved

Need help on Oracle sql

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

Question has a verified solution.

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

Suggested Solutions

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

773 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