15.01.2013 Views

Oracle Database 11g The Complete Reference (Osborne ORACLE ...

Oracle Database 11g The Complete Reference (Osborne ORACLE ...

Oracle Database 11g The Complete Reference (Osborne ORACLE ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 51: <strong>The</strong> Hitchhiker’s Guide to <strong>Database</strong> Administration 873<br />

Next, have <strong>Oracle</strong> move rows within the table to compress the allocation of rows within blocks:<br />

alter table BOOKSHELF_CHECKOUT shrink space compact;<br />

<strong>The</strong> shrink space compact operation will reorganize the rows of the table so they are stored<br />

more compactly. However, the high-water mark for the table—the highest block number to which<br />

rows have ever been written—is unaffected. Since all full table scans will read all blocks up to the<br />

high-water mark, you should adjust that value. You can adjust the high-water mark via the shrink<br />

space clause of the alter table command. For example:<br />

alter table BOOKSHELF_CHECKOUT shrink space;<br />

You can cascade the effects of this change to the table’s indexes via the shrink space cascade<br />

option.<br />

To predict space usage, you can use the OBJECT_GROWTH_TREND function of the DBMS_<br />

SPACE package. As parameters, pass the schema name, object name, and object type, as shown<br />

in the following listing. You should run this as a SYSDBA-privileged user.<br />

select * from<br />

table(DBMS_SPACE.OBJECT_GROWTH_TREND<br />

('PRACTICE','BOOKSHELF_CHECKOUT','TABLE'));<br />

<strong>The</strong> output will show the past space usage for the object along with projected space<br />

requirements for the object. <strong>The</strong> results are based on statistics gathered via the Automated Workload<br />

Repository (AWR). Using the MMON background process, AWR collects and stores database<br />

statistics that support administration and tuning on an hourly basis. <strong>The</strong> information gathered via<br />

AWR allows <strong>Oracle</strong> to project your future space usage as well as identify tuning opportunities.<br />

Transporting Tablespaces<br />

A transportable tablespace is a tablespace that can be “unplugged” from one database and<br />

“plugged into” another. To be transportable, a tablespace—or a set of tablespaces—must be<br />

self-contained. <strong>The</strong> tablespace set cannot contain any objects that refer to objects in other<br />

tablespaces. Thus, if you transport a tablespace containing indexes, you must move the tablespace<br />

containing the indexes’ base tables as part of the same transportable tablespace set. <strong>The</strong> better<br />

you have organized and distributed your objects among tablespaces, the easier it is to generate<br />

a self-contained set of tablespaces to transport.<br />

To transport tablespaces, you need to generate a tablespace set, copy or move that tablespace<br />

set to the new database, and plug the set into the new database. <strong>The</strong> databases must be on the<br />

same operating system, with the same version of <strong>Oracle</strong> and character set.<br />

Generating a Transportable Tablespace Set<br />

A transportable tablespace set contains all of the datafiles for the tablespaces being moved, along<br />

with an export of the metadata for those tablespaces. You can optionally choose whether to include<br />

referential integrity constraints as part of the transportable tablespace set. If you choose to use<br />

referential integrity constraints, the transportable tablespace set will increase to include the tables<br />

required to maintain the key relationships. Referential integrity is optional because you may have<br />

the same code tables in multiple databases. For example, you may be planning to move a<br />

tablespace from your test database to your production database. If you have a COUNTRY table<br />

in the test database, then you may already have an identical COUNTRY table in the production

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!