Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Shrink Oracle tables with LONG datatypes

Posted on 2008-06-09
Medium Priority
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 on Linux
Question by:mjimison1956
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
  • 4
  • 2
  • 2
  • +1
LVL 35

Expert Comment

ID: 21744977
With a LONG, I beilieve the only option is exp/imp.
LVL 27

Expert Comment

ID: 21749349
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


Author Comment

ID: 21749900
Will recreating the table require a change to the application?  I can not make any changes to the application code.

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

LVL 35

Expert Comment

ID: 21759033
Changing from LONG to LOB will most likely require code changes in the applications.

Author Comment

ID: 21759090
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?

Accepted Solution

KICUSek earned 2000 total points
ID: 21760667
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?

Author Comment

ID: 21760710
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.


Expert Comment

ID: 21760784
So i think step 1 could be beneficial.
Updates are performed on long columns or only on rest of them?

Author Comment

ID: 21760937
On all columns.  

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

721 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