Solved

Long Data Type records Insert into Table.

Posted on 2004-10-05
7
957 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.

Join & Write a Comment

Suggested Solutions

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

757 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

22 Experts available now in Live!

Get 1:1 Help Now