DBA best practices: Logging by default in SQL*Plus

Several times I asked myself (or others asked me) what statements I executed or what results I had gotten from many days before. Of course I didn’t remember them anymore.

Here’s where one of my favorite SQL*Plus features comes in handy: spooling. You can have it log everything you do.

First, create a folder to store the logs. Mine is C:\Spool .
Second, add these lines to the login.sql file ( you can type “ed login” to do this ):

column dinstasdasd new_value myinstance noprint
select instance_name dinstasdasd from v$instance;

column dcolasdasd new_value mydate noprint
select to_char(sysdate,’YYYYMMDD-hh24mi’) dcolasdasd from dual;

spool C:\Spool\&myinstance.-&mydate.-&_user..txt

This entry was posted in Best Practices, Oracle and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s