Solved

Long Data Type records Insert into Table.

Posted on 2004-10-05
7
958 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
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

862 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now