Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

varchar to clob

Status
Not open for further replies.

dinshak

Technical User
Oct 31, 2007
39
US
need to change varchar field that has data to clob?
 
Here is the conventional wisdom on "changing" a VARCHAR2 column to CLOB:
Code:
SQL> desc dinshak
 Name                                      Null?    Type
 ----------------------------------------- -------- ------------
 NAME                                      NOT NULL VARCHAR2(50)

SQL> select * from dinshak;

NAME
--------------------------------------------------
North America
South America
Africa / Middle East
Asia
Europe
Australia

6 rows selected.

SQL> alter table dinshak add x clob;

Table altered.

SQL> update dinshak set x = name;

6 rows updated.

SQL> alter table dinshak drop column name;

Table altered.

SQL> alter table dinshak rename column x to name;

Table altered.

SQL> select * from dinshak;

NAME
--------------------------------------------------------
North America
South America
Africa / Middle East
Asia
Europe
Australia

6 rows selected.

SQL> desc dinshak
 Name                                      Null?    Type
 ----------------------------------------- -------- ----
 NAME                                               CLOB
Let us know your reactions.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Hi,
Thank you for replying.

I should have mentioned earlier that the steps are successful till SQL> update dinshak set x = name;
it shows successfuly completed but when I go to view edit comments to look at the data it is empty.
 
Sounds like you viewed your changes from another session, which requires your doing a COMMIT in your original session. Could that explain the (mis)behaviour?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
can you be more specific as i am new to this.
 
i am trying to view it from enterprise manager console
 
where exactly should i use the commit statement. i used it after update but still the clob fields are empty.
 
Sorry for the delay, dinshak (I had to do some actual work for a few minutes. <grin>)
dinshak said:
where exactly should i use the commit statement. i used it after update but still the clob fields are empty.
That is puzzling...you should be able to see the new CLOB contents immediately from the session where you did the update, and from any other venue/session following the COMMIT.


If (from SQL*Plus or some other SQL-executing application) you do a "SELECT COUNT(<varchar2 column name>) FROM <table_name>;" what is the numeric result?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top