Solved

Shrink Oracle tables with LONG datatypes

Posted on 2008-06-09
9
1,495 Views
Last Modified: 2013-12-19
What is the preferred method to shrink a table that contains a LONG Datatype?  I can not change the data type due to the third party software application.  I need to find a way to shrink these tables.

Would it benefit to have all tables with LONG's in them in a separate table space.  Tables range in size from 50 rows to 4mm rows.

Version is 10.2.0.2 on Linux
0
Comment
Question by:mjimison1956
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 34

Expert Comment

by:johnsone
Comment Utility
With a LONG, I beilieve the only option is exp/imp.
0
 
LVL 27

Expert Comment

by:sujith80
Comment Utility
LONG datatype is already depricated by oracle. A better way will be to re-create the tables using LOB data types. LOBs offer a lot of flexibilities and features.
See the illustration below.



SQL> create table t1(id number, val long);
 

Table created.
 

SQL> insert into t1 values(10, 'test');
 

1 row created.
 

SQL> commit;
 

Commit complete.
 

SQL> create table t2 as select id, to_lob(val) val from t1;
 

Table created.
 

SQL> desc t2

 Name                                            Null?    Type

 ----------------------------------------------- -------- --------

 ID                                                       NUMBER

 VAL                                                      CLOB
 

SQL> select * from t2;
 

        ID VAL

---------- -----------------------------------------------------

        10 test

Open in new window

0
 

Author Comment

by:mjimison1956
Comment Utility
Will recreating the table require a change to the application?  I can not make any changes to the application code.

0
 
LVL 34

Expert Comment

by:johnsone
Comment Utility
Changing from LONG to LOB will most likely require code changes in the applications.
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.

 

Author Comment

by:mjimison1956
Comment Utility
Can not change the application due to cost and project.  What a mess.  Performance is terrible on these longs.

Any ideas on how to improve performance?
0
 
LVL 4

Accepted Solution

by:
KICUSek earned 500 total points
Comment Utility
My proposition:
1/ create separate tablespace with possibly large datablocks (16/32kB - depends on platform)
2/ migrate tables to new tablespace (exp/imp or other piece of code)

What operations are most common on this tables? inserts/updates/deletes or just selects?
0
 

Author Comment

by:mjimison1956
Comment Utility
The tables are used to set up a data scenario.  For example.  hundreds and thousands of insert, updates on the table, then a select is executed against the newly formatted data, passed to the application server, when the app server is complete a delete of all the newly inserted and updated data is executed.

Non sequential reads, I/O, CPU and performance is a nightmare.  I am constantly rebuilding indexes which also need shrinks.

0
 
LVL 4

Expert Comment

by:KICUSek
Comment Utility
So i think step 1 could be beneficial.
Updates are performed on long columns or only on rest of them?
0
 

Author Comment

by:mjimison1956
Comment Utility
On all columns.  
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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
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.  …
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.
This video shows how to recover a database from a user managed backup

772 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

15 Experts available now in Live!

Get 1:1 Help Now