Team Fly 

Page 325

Object Type

Compression Property Inheritance Parent

Table

Tablespace

Materialized View

Tablespace

Partition

Table

TABLE 9-13. Compression Property Inheritance

The following listing demonstrates the creation of a table with compression enabled. Line 7 contains the keyword compress to tell Oracle that data compression is to be enabled.

 1 create table commission (
 2  sales_rep_id     number,
 3  prod_id          number,
 4  comm_date        date,
 5  comm_amt         number(10,2))
 6 tablespace comm_ts pctfree 5 initrans 1 maxtrans 255
 7 compress;

Because compression can be enabled or disabled at different points in an object's lifetime (say, by using an alter command), and because the compression action only occurs on new data being loaded, it is possible for an object to contain both compressed and uncompressed data at the same time.

Ask the Expert

Q: Can existing data in a table be compressed and uncompressed?

A: Yes. There are two methods. The first is by using an alter table statement such as

alter table sales
move compress;

The second method is by using the utilities contained in the dbms_redefinition package.

Team Fly 
0344