Databases Reference
In-Depth Information
dba_setup
Usually, you'll establish a common set of OS variables and aliases in the same manner for every database server.
When navigating among servers, you should set these variables and aliases in a consistent and repeatable manner.
Doing so helps you (or your team) operate efficiently in every environment. For example, it's extremely useful to have
the OS prompt set in a consistent way when you work with dozens of different servers. This helps you quickly identify
what box you're on, which OS user you're logged in as, and so on.
One technique is to store these standard settings in a script and then have that script executed automatically
when you log in to a server. I usually create a script named dba_setup to set these OS variables and aliases. You can
place this script in a directory such as HOME/bin and automatically execute the script via a startup script (see the
section “Organizing Scripts,” later in this chapter). Here are the contents of a typical dba_setup script:
# set prompt
PS1='[\h:\u:${ORACLE_SID}]$ '
#
export EDITOR=vi
export VISUAL=$EDITOR
export SQLPATH=$HOME/scripts
set -o vi
#
# list directories only
alias lsd="ls -p | grep /"
# show top cpu consuming processes
alias topc="ps -e -o pcpu,pid,user,tty,args | sort -n -k 1 -r | head"
# show top memory consuming processes
alias topm="ps -e -o pmem,pid,user,tty,args | sort -n -k 1 -r | head"
#
alias sqlp='sqlplus "/ as sysdba"'
alias shutdb='echo "shutdown immediate;" | sqlp'
alias startdb='echo "startup;" | sqlp'
dba_fcns
Use this script to store OS functions that help you navigate and operate in your database environment. Functions tend
to have more functionality than do aliases. You can be quite creative with the number and complexity of functions you
use. The idea is that you want a consistent and standard set of functions that you can call, no matter which database
server you're logged in to.
Place this script in a directory such as HOME/bin . Usually, you'll have this script automatically called when
you log in to a server via a startup script (see the section “Organizing Scripts,” later in this chapter). Here are some
typical functions you can use:
#-----------------------------------------------------------#
# show environment variables in sorted list
function envs {
if test -z "$1"
then /bin/env | /bin/sort
else /bin/env | /bin/sort | /bin/grep -i $1
fi
} # envs
#-----------------------------------------------------------#
# login to sqlplus
 
Search WWH ::




Custom Search