12

Table: customers

ID      NAME             DATATYPE
NUMBER  VARCHAR2(100)    CLOB

I want to change the DATA column from CLOB to `VARCHAR2(1000)

I have try ALTER TABLE customers MODIFY DATA VARCHAR2 (1000) also

ALTER TABLE customers MODIFY (DATA VARCHAR2 (1000))

also

alter table customers  modify
(data VARCHAR2(4000))

those normally works if the datatype is not a clob but I am getting a ORA-22859 because I am using oracle toad/apex.

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
PHPnoob
  • 293
  • 1
  • 3
  • 12

1 Answers1

25

You may try this:

  1. Add a new column as varchar2

    alter table my_table add (new_column varchar2(1000));

  2. UPDATE CLOB name to varchar2 column;

    update my_table set new_column=dbms_lob.substr(old_column,1000,1);

After testing your data:

  1. DROP CLOB column

    alter table my_table drop column old_column

  2. Rename varchar2 column to CLOB column name

    alter table my_table rename column new_column to old_column

Community
  • 1
  • 1
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
  • lol i was thinking the same but I can't do that. They should be away to change `clob` datatype – PHPnoob Nov 07 '13 at 17:04
  • `They should be away to change clob datatype`..What does that mean? – Rahul Tripathi Nov 07 '13 at 17:05
  • it means changing clob to varachar2 or number same as you can change a varachar2(100) to varchar2(1000) or vaachar2 to number, etc – PHPnoob Nov 07 '13 at 17:08
  • 1
    you want to me `add` a new colum while I am trying to change the existing colum `datatype` from clob to `varchar2` – PHPnoob Nov 07 '13 at 17:12
  • @PHPnoob:- I understand that but that would be the easiest one. Check this related thread: http://dba.stackexchange.com/questions/5948/how-to-replace-a-clob-column-by-a-varchar24000-column – Rahul Tripathi Nov 07 '13 at 17:13