Solved

Long Data Type records Insert into Table.

Posted on 2004-10-05
7
961 Views
Last Modified: 2012-06-22
How to copy the records from a table which has LONG Data type to another Table of the same structure.

From

Table1(
X varchar2(100)
Y number(10)
Z LONG )

copy to

Table2(
X varchar2(100)
Y number(10)
Z LONG )

Thanking in Advance...!
0
Comment
Question by:UMESHNC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 23

Expert Comment

by:seazodiac
ID: 12225542
try:

insert into Table2 select * from Table1;
0
 
LVL 15

Expert Comment

by:andrewst
ID: 12225836
> insert into Table2 select * from Table1;

Thst will give the error:
ORA-00997: illegal use of LONG datatype
0
 
LVL 15

Expert Comment

by:andrewst
ID: 12225875
You can:
- use the COPY command
- Write a PL/SQL program to do it, provided all the long values are <= 32K
- Write a Pro*C program to do it
- Convert it to CLOB:
create table Table2(
X varchar2(100)
Y number(10)
Z CLOB );

insert into Table2 select X, Y, TO_LOB(Z) from Table1;
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:wemy
ID: 12225963
In 8i you should not be using LONGS (long raws) they are deprecated types.

There are many restrictions with them -- this is one of them (not so with
CLOBS/BLOBS)

but you can use COPY command as the following:

SQL> copy from User_Name/Password@DB1 insert Table2 (X, Y, Z ) using select X,Y,Z from Table1;

or in the same Schema:

SQL> copy TO Table2 (X, Y, Z ) using select X,Y,Z from Table1;
 and you will be asked about the password of the TO DB.
 
You'll want to set

set arraysize N -- amount of rows the copy command will copy with each fetch
set long N -- size of your longest long
set copycommit M -- number of fetches to do before commit (N*M rows!!)
 
in plus before doing this.  see the manual for all the options....
0
 
LVL 9

Expert Comment

by:konektor
ID: 12226141
what about using export and import ? ...
0
 

Author Comment

by:UMESHNC
ID: 12226227
I am Using Oracle 9.2 release... but there are tables created when 8/8i was there .

Now how can i convert this tables which has long column into CLOB/BLOB.
Will this convertion effect any of my data in tables.


0
 
LVL 23

Accepted Solution

by:
seazodiac earned 125 total points
ID: 12226271


In Oracle9i , you can use this one-liner to change long column to LOB:

"alter table <table_name> modify <long col name>  CLOB"


this will not affect any of your data.
 
 
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Oracle encryption 12 70
SQL2016 to ORACLE11G linked-server 6 76
error in oracle form 11 50
Oracle Mulit-site configuration 28 72
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question