Skip to Main Content
  • Questions
  • Convert Long and long raw data type to clob or blob

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Arjun.

Asked: June 20, 2020 - 6:14 am UTC

Last updated: June 23, 2020 - 3:31 am UTC

Version: 12c

Viewed 1000+ times

You Asked

Hi All.

We have issue in moving object from one table space to another with long data type.

We also have few object with long raw data type tables. I need to try this move to new table space.

I found a document in metalink convert long data type into clob using "TO_LOB".

Long got converted in to CLOB.

Question : are we good to use to_lob?
For long and long raw data type conversion.

Will there be any data corruption ?

If any other input please share.



-Thanks
-Arjun Bangaru.

and Connor said...

Its even easier than that....You can migrate directly and forget about LONG and LONG RAW forever :-)

SQL> create table t1 ( c1 long );

Table created.

SQL> create table t2 ( c2 long raw);

Table created.

SQL>
SQL> exec   insert into t1 values ('xxxxxx');

PL/SQL procedure successfully completed.

SQL> exec   insert into t2 values ( hextoraw('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'));

PL/SQL procedure successfully completed.

SQL>
SQL> commit;

Commit complete.

SQL>
SQL> alter table t1 modify c1 clob;

Table altered.

SQL> alter table t2 modify c2 blob;

Table altered.

SQL> select * from t1;

C1
----------------------------------------------------------------------------------------------------------------------------------
xxxxxx

1 row selected.

SQL> select * from t2;

C2
----------------------------------------------------------------------------------------------------------------------------------
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

1 row selected.

SQL>


Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Arjun Bangaru., June 22, 2020 - 3:42 am UTC

Awesome.

Thanks a lot.

-Thanks
-Arjun Bangaru.
Connor McDonald
June 23, 2020 - 3:31 am UTC

glad we could help

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database