How to Convert the Data Type VARCHAR2 to CLOB in Oracle

We cannot directly convert the data type VARCHAR2 to CLOB(Character Large OBject). Using below two options, we can able to covert it.

Option 1:

Step 1 : Convert the VARCHAR2 To LONG Data Type
Step 2 : Convert the LONG to CLOB Data Type.

Example:

Step 1: ALTER TABLE YOUR_TABLE_NAME MODIFY(Your_Column_Name LONG);
Step 2: ALTER TABLE YOUR_TABLE_NAME MODIFY(Your_Column_Name CLOB;

Option 2:

Step 1: Add a new column as CLOB
Step 2: UPDATE VARCHAR2 date to CLOB column
Step 3: DROP VARCHAR column
Step 4: Rename CLOB column to VARCHAR column name

Leave a Reply

Your email address will not be published. Required fields are marked *

*

ss