05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 9 ■ REDO AND UNDO 331<br />

17 close c;<br />

18 exception<br />

19 when others then<br />

20 dbms_output.put_line( 'rows fetched = ' || l_rowcnt );<br />

21 raise;<br />

22 end;<br />

23 /<br />

rows fetched = 253<br />

declare<br />

*<br />

ERROR at line 1:<br />

ORA-01555: snapshot too old: rollback segment number 23 with name "_SYSSMU23$"<br />

too small<br />

ORA-06512: at line 21<br />

As you can see, it got to process only 253 records before failing with the ORA-01555:<br />

snapshot too old error. To correct this, we want to make sure two things are done:<br />

• UNDO_RETENTION is set in the database to be at least long enough for this read process to<br />

complete. That will allow the database to grow the undo tablespace to hold sufficient<br />

undo for us to complete.<br />

• The undo tablespace is allowed to grow or you manually allocate more disk space to it.<br />

For this example, I have determined my long-running process takes about 600 seconds to<br />

complete. My UNDO_RETENTION is set to 900 (this is in seconds, so the undo retention is about<br />

15 minutes). I altered the undo tablespace’s data file to permit it to grow by 1MB at a time, up<br />

to 2GB in size:<br />

ops$tkyte@ORA10G> column file_name new_val F<br />

ops$tkyte@ORA10G> select file_name<br />

2 from dba_data_files<br />

3 where tablespace_name = 'UNDO_SMALL';<br />

FILE_NAME<br />

------------------------------<br />

/home/ora10g/oradata/ora10g/OR<br />

A10G/datafile/o1_mf_undo_sma_1<br />

729wn1h_.dbf<br />

ops$tkyte@ORA10G> alter database<br />

2 datafile '&F'<br />

3 autoextend on<br />

4 next 1m<br />

5 maxsize 2048m;<br />

old 2: datafile '&F'<br />

new 2: datafile '/home/ora10g/.../o1_mf_undo_sma_1729wn1h_.dbf'<br />

<strong>Database</strong> altered.

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

Saved successfully!

Ooh no, something went wrong!