About Me

The best place to start learning Oracle, Linux/Unix scripting, and Oracle administration skills. Currently, as Oracle DBA with 11g/10g/9i OCP certified, I want to help you with my background and knowledge. Hopefully, this info would help you as a job aid.

Saturday, November 5, 2011

Oracle Fundamental I - Chapter 2: Started with oracle Server

Database Administration Tools

Tools
Description
Oracle Universal Installer (OUI)
Used to install, upgrade, or remove software components with GUI interface.

Oracle Database Configuration Assistant
A graphical user interface tool that interacts with the OUI, or can be used independently, to create, delete, or modify a database.
SQL *Plus
A utility to access data in an oracle database. The mostly used tool by DBA to administrating the database/instance.
DB console (Oracle Enterprise Manager in previous version as 9i)
A graphical interface used to administer, monitor, and tune one or more databases.


The Oracld Universal Installer is a Java based engine, which provides the GUI interface to administrates the installation process.

To start OUI in Unix/Linux environment,  the installation program is called runInstaller,
which is located under oracle\oui\install direcotry, you issue the following command:

$ ./runInstaller


To start OUI on NT environment, the installation program is calle Setup,
which is located under Program Files/Oracle/oui/install, you issue the following steps:

Start  >  Programes  >  Oracle Installation Products  >  Universal Installer




Oracle Database Configuration Assitant can be used for the following:
- Create a database
- Configure database options
- Delete a database
- Manage templates

When creating a new database, DBCA will prompt you for setup the administrative level privilege.
To administrates an Oracle database, you need those privilege for appropriate acceses.
  • Users sys and system are created automatically
    • During database creation
    • Granted the DBA role (DBA role is a default bunch of privilege created duing Oracle installation to provide DBA level privilege)
  • User Sys
    • Owner of the database data dictionary
    • Default password: change_on_install
  • User System
    • Owner of additional internal tables and views user by Oracle tools.
    • Default password: manager
If you use DBCA to create a database, you will get the chance to modify the passwords during the creation process.


SQL*Plus is an Oracle tool, which provides:
  • capability to interact with and manipulate the database, which is based on the command prompt interface. SQL and PL/SQL is the languages used by SQL*PLus.
  • Ability to startup and shutdown the database, create and run queries, add/update/delete/query rows, data and write reports, etc.
  • Connecting to SQL*Plus:
    • By default, SQL*Plus is located under $ORACLE_HOME/bin

$ sqlplus /nolog
SQL> connect / as sysdba
Connected to an idle instance.

                          

Oracle DB console (Oracle Enterprise Manager in 9i or previous) is the Oracle tool based on GUI interface to administrate Oracle instance and database.
  • Serves as centralized systems management tool for DBAs.
  • A tool to administer, diagnose, and tune multiple databases.
  • A tool to administer multiple network nodes and services from many locations.
  • Use to share tasks with other administrators.
  • Provices tools for administering parallel services and replicated databases.


KSH - Korn Shell Tutorial

KSH - Korn Shell Tutorial
  • Matching Patterns
  • Conditional Statements
  • Test Objects (Files, Directories, etc.)
  • Format of flow control functions
  • Positional Parameter
  • Redirections
  • Other functionalities
  • Examples
  • Regular Expression
  • Array


Matching Patterns
pattern:    example:      matches:                    not matched:
------------------------------------------------------------------
*           boo*          boot,boo,booth

?           boo?          boot                        booth
[...]       [aeiou]*      ark                         bark
[!...]      boo[!st]      boor                        boot
*(cc|cc)    boo*(ze|r)    boo,boor,booze,boozer       boot
+(cc|cc)    boo+(ze|r)    boor,booze,boozer           boo
?(cc|cc)    boo?(ze|r)    boo,boor,booze              boozer
@(cc|cc)    boo@(ze|r)    booze,booth                 boo
!(cc|cc)    boo!(ze|r)    booth,boo,boot              booze,boor
{c,c,c}     a{b,c,d}e     abe,ace,ade                 axe



Conditional Statements
format                           "true" if:
---------------------------------------------------
(( _num1_ == _num2_ ))           numbers equal
(( _num1_ != _num2_ ))           numbers not equal
(( _num1_ < _num2_ ))            num1 < num2
(( _num1_ > _num2_ ))            num1 > num2
(( _num1_ <= _num2_ ))           num1 <= num2
(( _num1_ >= _num2_ ))           num1 >= num2

[[ _str1_ == _str2_ ]]           strings equal
[[ _str1_ != _str2_ ]]           strings not equal
[[ _str1_ < _str2_ ]]            str1 precedes str2
[[ _str1_ > _str2_ ]]            str1 follow str2
[[ _str1_ = _pattern_ ]]         str1 = pattern
[[ _str1_ != _pattern_ ]]        str1 != pattern
[[ -z _str_ ]]                   str is null
[[ -n _str_ ]]                   str is not null

[ x=y -o k=j ]                   or in expression
[ x=y -a k=j ]                   and in expression



Test Objects (Files, Directories, etc.)
test "true" if:                 ksh
-----------------------------------
object exist                    -a
readable                        -r
writable                        -w
executable                      -x
non-zero length                 -s
zero length


directory                       -d
plain file                      -f
symbolic link                   -h
named pipe                      -p
block special file              -b
character special file          -c
soft link                       -L
socket                          -S

owned by me                     -O
owned by my group              not

"sticky" bit set                -k
set-group-ID bit set            -g
set-user-id bit set             -u

opened on a terminal           not



Format of flow control functions
"if-then"               if _expr_ then
                            _cmd(s)_
                        elif _expr_
                            _cmd(s)_
                        else
                            _cmd(s)_
                        fi

"case"                  case _word_ in
                            _pattern1_)   _cmd(s)_
                            _pattern2_)   _cmd(s)_
                            *)            break ;;
                        esac

"while"                 while _expr_ do
                            _cmd(s)_
                        done

"for"                   for _variable_ in _list_
                            _cmd(s)_
                        done

"until"                 until _expr_
                        do
                            _cmd(s)_
                        done



POSITIONAL PARAMETER
program, function or shell                         $0
argument 1 through 9                               $1 .. $9
nth argument                                       ${n}
number of positional parameters                    $#
every positional parameter                         $@, $*
decimal value returned by last executed cmd        $?
pid of shell                                       $$
pid of last backgrounded command                   $!



REDIRECTIONS
0             stdin
1             stdout
2             stderr

<&-           close stdin
>&-           close stdout
<>filename    open filename for read-write
2>&1          open 2 for write and dup as 1

Examples:
  cmd 2>/dev/null
  cmd >/dev/null 2>&1
  exec 1<&-           # close descriptor 1
  exec 2<&-           # close descriptor 2
  exec 1< /dev/null   # open descriptor 1
  exec 2< /dev/null   # open descriptor 2


 

OTHER FUNCTIONALITIES
cmd1 || cmd2    exec cmd2 if cmd1 fail
cmd1 && cmd2    exec cmd2 if cmd1 is OK

V1=${V2:=V3}    Set V1 with the value of V2 if this is set else set the
                variable V1 with value of V3 (V3 could be a number).
                sh replacement:  if [ $V2 ] ; then
                                                V1=$V2
                                 else
                                                V1=$V3
                Example: DisplaySize=${LINES:24} ; Command=${Command:"cat"}


${V1:?word}     if V1 set  & V1!=null   ret $V1 else print word and exit
                  : ${V1:?"variable V1 not set on null"}
${V1:=word}     if V1 !set | V1==null   set V1=$word
${V1:-word}     if V1 set  & V1!=null   ret $V1 else ret word
${V1:+word}     if V1 set  & V1!=null   ret word else ret nothing
${V1##patt}
${V1#patt}      if patt are found at the begin of V1 return V1 whitout the patt
                else return V1
                V1="lspwd" ; ${V1#"ls"}  # exec pwd
${V1%%patt}
${V1%patt}      if patt are found at the end of V1 return V1 whitout the patt
                else return V1
                V1="lspwd" ; ${V1%"pwd"}  # exec ls



EXAMPLES
- Explode a command for use parameters counter
    set `who -r` ; [ "$8" != "0" ] && exit

- declare a variable for only uppercase/lovercase chars
    typeset -u VAR ; VAR="lower" ; echo $VAR   -> LOWER
    typeset -l VAR ; VAR="UPPER" ; echo $VAR   -> upper

- exec

- eval - esegue il comando dato come argomento

- let - esegue le operazioni matematiche che passate come argomento
 let "x = x * 5"
 ((x = x * 5))  .. altra forma di let




REGULAR EXPRESSION
- ritorna la prima lettera dopo il segno - all'inizio di una stringa
    VAR="-ciao"
    RESULT=`expr "$VAR" : "-\(.\)"`
    echo $RESULT        .. -c
- toglie il '-' iniziale
    VAR="-ciao"
    VAR=`expr "$VAR" : "-*\(.*\)"`
    echo $VAR           .. ciao
- ritorna la lunghezza di una stringa
    VAR="ciao"
    echo `expr length $SHELL`      .. 4
- ritorna l'indice di dove incontra una substringa
    echo `expr index abcdef de`    .. 4
- ritorna 6 caratteri a partire dall'11
    expr substr "Goodnight Ladies" 11 6     .. Ladies



ARRAY
- definisce un array
 set -A Week Sat Sun Mon Tue Wed Thu Fri
- ritorna un elemento dell'array
 echo ${Week[3]}       .. Tue
 id=3 ; echo ${Week[id]}     .. Tue
- stampa tutti gli elemti di un array
 echo ${Week[@]}       .. Sat Sun Mon Tue Wed Thu Fri
- scandisce un array
    for day in ${Week[@]}
    do
        echo $day
    done
- ritorna il numero di elementi in un array
 nelem=${#Week[@]} ; echo $nelem   .. 7

Quick Unix Tutorial

Quick Unix Tutorial

Examples of Basic Commands



 Action 


 Command 


 Examples 
appent to file cat >> cat >> file1
combine 2 files cat cat file1 file2 > file3
copy files cp cp myfile copymyfile
create a file cat cat > newfile
edit files vi vi file
list files ls ls bin/
move a file mv mv file1 doc/chapter1
remove a file rm rm unwantedfile
rename a file mv mv oldfilename newfilename
view files cat
pg
more
less
view
cat file
pg file2 file3
view file6 file7


 Directories 


 Command 


 Examples 
change to another directory cd cd example/first/
create a directory mkdir mkdir example1
find out where you are pwd pwd
go to your home directory cd cd
remove an emplty eirectory rmdir rmdir junk
Redirection of Output or Input
>
   redirects the output of a command to a file
>>  redircts the output of a command to the end of an existing file
<    takes the input of a command form a file, not the terminal

Summary of Basic Commands

  • apropos  locate commands by keyword lookup
  • arch  display the architecture of the current host
  • cal  display a calendar
    cal [month] year
    • month   number between 1 and 12
    • year      number between 1 and 9999
    Examples:
    cal 1996      print calendar for year 1996
    cal 1 1997   print calendar for January 1997
  • cancel  send/cancel requests to an LP print service
  • cat  concatenate and display files (To view files, create files, append to files and combine files)
    cat [options] [files]
    Examples:
    cat files                read file(s)
    cat > file              create file (reads form terminal; terminate input with ^D)
    cat >> file            append to file (reads form terminal; terminate input with ^D)
    cat file2 >> file1   appends contents of file2 to file1
  • cd  shell built-in functions to change the current working directory
  • chdir  shell built-in functions to change the current working directory
  • chgrp  change the group ownership of a file
  • chmod  change the permissions mode of a file
  • chown  change owner of file
  • clear  clear the terminal screen
  • cp  copy files
  • date  print and set the date
  • dc  arbitrary precision desktop calculator
  • dos2unix  convert text file from DOS format to ISO format
  • eject  eject media such as CD-ROM and floppy from drive
  • exit  shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps
  • file  determine the type of a file by examining its contents
  • head  display first few lines of files
  • lp  send/cancel requests to an LP print service
  • lpstat  print information about the status of the LP print service
  • ls  list the contents of a directory
    ls [options] [directories]
    the current working directory used if no directories specified
    A few options:
    • -a    list all entries includeing hidden files (starting with .)
    • -i    print inode numbers
    • -l    long list (mode, links, owner, group, size, timeof last modification, and name
    • -t    sort by modification time
    • -x    multi-column list, sorted across each row
  • Mail, mailx, mail rmail interactive message processing system to read mail or send mail to users
    mail [options] users
    Examples:
    mail                           with no options, to read your mail
    mail user                     to send mail to user
    mail user < filename     mail a file to another user
  • mkdir  make directories
  • more  browse or page through a text file
  • mv  move files
  • nispasswd  change NIS+ password information
  • page  browse or page through a text file
  • pg  files perusal filter for CRTs
  • pr  print files
  • ps  display the status of current processes
  • pwd  working directory name
  • rm  remove files or directories
  • rmdir  remove files or directories
  • spell  find spelling errors
  • tail  deliver the last part of a file
  • umask  shell built-in function to restrict read/write/execute permissions
  • unix2dos  convert text file from ISO format to DOS format
  • vi  screen-oriented (visual) display editor based on ex
  • view  screen-oriented (visual) display editor based on ex
  • w who is logged in, and what are they doing
  • wc  display a count of lines, words and characters in a file
  • which  locate a command; display its pathname or alias
  • who  who is on the system
  • whoami  display the effective current username
  • whois  Internet user name directory service
  • write write to another user