Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Oracle > Converting CLOB to VARCHAR2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-03-08, 12:46
chuck_forbes chuck_forbes is offline
Registered User
 
Join Date: Dec 2003
Posts: 848
Converting CLOB to VARCHAR2

So, we want to convert some columns from CLOB to VARCHAR2. Can I just do something like the following, or will some CLOB data get lost if I don't use something from DBMS_LOB, or something, to convert the data. As a critical note, the data in the CLOB column doesn't exceed 800 characters, and the VARCHAR2 we're creating holds 2000:

Code:
— add the "soon-to-be" DIRECTIONS column, naming it something novel ALTER TABLE PUBEDUC.EDUDRECT ADD (DIRECTIONS_NEW VARCHAR2(2000)); — move the data from the CLOB column into the VARCHAR2 column UDPATE PUBEDUC.EDUDRECT SET DIRECTIONS_NEW = DIRECTIONS; — remove the CLOB column ALTER TABLE PUBEDUC.EDUDRECT DROP COLUMN DIRECTIONS; — rename the VARCHAR2 column back to the original field name ALTER TABLE PUBEDUC.EDUDRECT RENAME COLUMN DIRECTIONS_NEW TO DIRECTIONS;

---=cf
Reply With Quote
  #2 (permalink)  
Old 01-05-08, 01:32
ebrian ebrian is offline
Registered User
 
Join Date: May 2006
Posts: 117
Yes, that will work.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On