You are on page 1of 62

1

MADHAV K
UNIX COMMANDS
1. $ LOGNAME : It displays the current user information
2. $PWD : present working directory
3. $DATE : It displays the system date & time
4. $clear : To clear the screen
. $cal : it current month and year
!. $cal 2000 : "isplays the 2### year calendar
$. $cal 8 2006 : displays the %
th
month of 2##!
%. $exit or logout : e&it from current user account
'. $ who : displays the all user in who are currently working on ser(er
1#. $i!ger : displays the all user who are currently working on ser(er with
more information
11. Who a" # : displays current user information
12. Which or where : displays the location of the gi(en command
)yn: $which pwd
13. $at : is use to create new files or to open e&iting files or to append
data to the e&iting files
$reate: cat *filename
+++++++++++
+++++++++++cntl,d
%e&irect' cat file1 file2 file3 *file4++++++++re&irect out(ut
A((e!&: cat **filename++++++++ )i!gle ile $cat file1 file2 file3 **-./++++++"ulti
files
+++++++++++
+++++++++++cntl,d
O(e! ile' cat *ile!a"e+++++o(e! )i!gle file $cat file10 file20 file3++++++++++to o(e!
"ulti files
1at *.filename+++++++++for hi&&e! files
2
MADHAV K
14. Touch : It is used to create an empty file i.e. # 2yte file
)34: $ touch filename
$ touch file1 file2 file3+++++++++ create multiple files
1. r" : deleting files or directories
-5
rm filename++++++++++++++++deleting single file
rm +i filename++++++++++++++deleting files with confirmation
rm file1 file2++++++++++++++++deleting multiple files
rmdir dirname++++++++++++++deleting the directory 2ut the directory must 2e empty
rm +r dirname+++++++++++++deleting directory recursi(ely 6i.e. with tree str7
rm 8ri dirname+++++++++++++remo(e directory with confirmation
rm 9 +++++++++++++++++++++ it delets all files
rm +I 9++++++++++++++++++++delets all files with confirmation
rm t9 +++++++++++++++++++++it delets whose file name starts with :t;
1!. ",&ir : creating directories
)yn: $mkdir dirname
)ys: $.kdir .dirname++++++++++++hidden directory
1$. $& : change directory
)ys: $cd a2c
$pwd++++++<home<madha(<a2c using a2o(e cmd we can come out from a2c now we
at <<home<madha(
cd..+++++++++++++++++++++++++++to come out from current directory
cd..<..++++++++++++++++++++++++parent directory
cd<+++++++++++++++++++++++++++it changes to root directory
cd =+++++++++++++++++++++++++it changes to home directory
3
MADHAV K
1%. c( :copy source file to target file
-&
1p emp1 emp2++++++++++++++++++++++emp1 tp 2 coping
1p 8I m1 m2+++++++++++++++++++++++++o(erwrite confirmation> 3
1p 8? source directory to target directory+++++++cp 8? a2c &y@
1'. "- : it is used to rename or mo(e file
-&: m( e&iting filename new filename
.( emp .emp++++++++++++++++++++++to hide
.( .emp emp++++++++++++++++++++to unhide
2#.l) : display0 list of all files & directories in a current directory
21.l)."ore : display0 list of all files & directories page 2y page
22. l) /a : display0 list of all files & directories including hidden files and
dirctories also in current directory
23. l) /r : display list of all files & directories re(ers order in a current directory
24. L) /% : display list of all files & directories recursi(ely in a current directory
2. L) /t : display list of all files & directories according to date of creation in a
current directory
2!. L) /0 : display all list of files & directories0 link files0 .e&e files in a current
directory
2$. L)+x : display all list of files & directories according to width wise in a
current directory
2%. L)+L : display all list of files & directories in a current directory in a long list
i.e. ' fields
12 0ile t3(e)
A17 ++ Bor regular file ii7 dCfor dir file III7 DCfor link file IE2 2Cfor
2lock of filesE7 cC for char filesF Ahere IE0 E is &e-ice ile)4
27 Bile permissions 37 no. of links 47 owner name 7 group name !7 file si@e in 2ytes
$7 "ate %7 time '7 filename
4
MADHAV K
3#. c"( : it compares two files char 2y char
)ys: cmp file1 file2
-&: a1: Gello Hood .orning
a2: Gello Hood -(ening
If two lines are same then return nothing
If two files are are different then it displays line num2er with character position
31. co"". : It display common lines 2<w 2 files
)yn: 1omm Bile1 file2
32. &i : it display different lines 2<w 2 files
33. (g : it display the file contents page 2y page
)yn: $/g filename
34. "ore : it also display the file contents page 2y page
)yn: $more filename
34. hea& :it display the 1
st
n lines from the file
)ys: $ head 8n filename
3. tail : it display the last n lines from file
)yn: tail 8n filename
Tail ,n filename++++it indicates nth line to end of the line
-&: tail ,3# file 6in this file total no of records is 1##7 it displays the records from 3#
th
to
1##
3!. wc : it counts the no of lines0 words0 chars in a gi(en file.
)yn: $wc filename
i7 wc 8l filename++++++++++++++++++it gi(es the no of lines in a gi(en file
ii7 wc 8w filename+++++++++++++++it gi(es the no of words in a gi(en file
III7 wc 8c filename+++++++++++++++ it gi(es no. of char in file
i(7 wc +lw filename++++++++++++++ it gi(es the no of lines and character in a gi(en file
5
MADHAV K
3$. IID" 1J?" 1GJ?1T-?) or .-TJ 1GJ?1T-?)
i7 :9;++++++++it matches :#; or more chars
ii7 :>; +++++++it matches any single chars
iii7 A F +++it matches any single chars in the gi(en list
i(7 :8:++++++it matches any single char in the gi(en range
1) ls t9+++++++++++++++it list the files starts with :t;
2) ls 9s +++++++++++++it list the files that ends with :);
3) ls 29k++++++++++++++it list the files starts with :2; and ends with :k;
4) ls a>++++++++++++++it list the 2 characters filename 1
st
later fallowed 2y :a; and
second letter is any one character
5) lsA2kntF+++++++++++it list the files starts with :2; or :k; or :n; or :t;
6) ls Aa2cdefghF or lsAa+hF9++list the files0 first char 2<w :a; to :h;
7) ls A2+kFAp+tFAd+nF9+++++++++ it list the files the 1
st
character :2; to :k; 2
nd
char :p; to :t;
3
rd
char :d; to :n; after that any no of characters
3%. gre( : Aglo2ally search a regular e&pression and print itF
Is used for to search a string or regular e&pression in a gi(en file6s7
I7 -g: $ grep madha( sample
K<p: 2nd line

th
line
6
MADHAV K
$
th
line
ii7 -g: $grep madha( a10 a20 a3:
a1:++++++
a2:++++++
a3:++++++
iii7 $ grep techno 9++++++it searches for techno in current dir files 6all files7
i(7 $grep techno soft sample+++++it searches for more than one word
Ie kept it in L L
(7 $grep Ltechno softM sample
gre( c"& o(tio!)
$ grep 8i techno sample+++++++++++++++++++++++ignore case sensiti(e
$ grep 8c techno sample+++++++++++++++++++++++count no of lines
$grep 8n techno sample+++++++++++++++++++++++print along with the line num2ers
$grep 8l techno 9++++++++++++++++++++++++++++++list only file names
$grep 8( Ltechno softM sample+++++++++++++++not matches print the lines
$grep 8ci techno sample++++++++++++++++++++++Ignore case sensiti(e found no of lines
$grep Ltechno 9M sample+++++++++++++++++++++pattern
%egular ex(re))io!' any string contains wildcard charctor knows as regular e&pression or
pattern
These patterns are of 5 t3(e):
$harctor (atter!: the default pattern is char pattern only
i7 $grep Ltechno 9M sample
ii7 $grep L2 AaeiouF llM sample
iii7 $grep L2..dM sample+++i.e. or matches any single charctor
Wor& (atter! :<N <*
<N +++++++start of the word
<*++++++end of the word
7
MADHAV K
Hrep L<Ntechno<*M sample ++++++++++++o<p: techno
Hrep L<NtechnoM sample++++++++++++++++o<p: techno soft
+++++++++++++++++o<p: techno 123
Hrep Ltechno<*M sample ++++o<p: hellotechno0 a2ctechno
Hrep L<N A#+'FA#+'FA#+'FA#+'F<*M sample++++++++++++++it display 4 digits
6i.e.12340 4!$7
Li!e (atter!' 6++++++++++starts of the file
$++++++++++ends of the file
-&: grep LOdM sample+++++++++++++++it display the line starts with:d;
Hrep LOtheM sample+++++++++++++++++it list the lines start with :the;
Hrep LO<Nthe<*M simple ++++++++++sample the line e&actly start with :the;
Hrep Lt$M simple+++++++++++++++++++list the line ends with:t; or last char is:t;
Hrep LA#+'F $M sample++++++++++++ display the line ends with # to ' digit
Hrep LO A2ktFM sample++++++++++++list the line starting with :2; or :k :or;t;
Hrep LO AO2ktFM sample++++++++++list the line which is not start with :2; or :k; or:t;
Hrep LMOP4I5$M sample +++++++++display the line ha(ing only word :Pni&;
Hrep LOQ. $M++++++++++++++++++++++list the line which contains :4; characters
6.7++++++++++++++++++++++++++++++++++represent single charctor
Hrep LO.M++++++++++++++++++++++++)ample it list all lines
Hrep L<.M )ample: ++++++++++++++it lists the line start with 6.7
Ie use R to search 90 $0 O as a charctor+++++++ i.e.R90SO0R$
Hrep LO$M sample++++++++++++++ it list empty lines
Hrep 8c LO$M sample++++++++++counts no of empty lines in a file
Hrep 8( LO$M sample++++++++++print not matches 6i.e. not empty7 lines
Hrep 8( LO$Msample *temp
.( temp sample+++++++++++++++++++here 2oth are delete empty files
8
MADHAV K
3'. gre( : it is used for search multiple strings 2ut it doesn;t allow to search regular
e&pression
$grep Lhello
*techno
*P4I5Msample++++++++++it searches for hello or techno str P4I5
4#. egre( : it is com2ination of grep and fgrep
$egrep Lhello
*hello
*P4I5Msample $egrep LO$M sample
41. 7e& : to replace a string
$ sed Ls<e&isting string<new string<gM filename++sed is used to find and replace and grep
is for find print
i7 $sed Ls<Pni&<Dinu&<gi Lmadha(: +++++++++++++ :i :for case sensiti(e
ii7 $sed Ls<OPni&<Dinu&<giM++++++++++++++++++++++ whate(er lines starting with P4I5 are
replaced 2y Dinu&
iii7 $sed Ls<O$<I like Pni&<g IM sample++++++++empty string are filled with :I like P4I5;;
i(7 $)ed Ls<Pni&<<g IM sample+++++++++++++++++it search P4I5 if found replace with :nothing;
6empty7
42. tr : to translate a charctor
i7 tr LaM LpM Ns++++++++++++++++++++ it read data from sample and :a; is replaced 2y :p;
ii7 tr LaeiouM LJ-IKPMNsample++++replace char 2y char
iii7 tr L0M LltM Nemp++++++++++++++++whene(er L0M is there replace with ta2 space
i(7 tr LAa+@FM LAJ+TF N)i(a++++++++ con(erts hole file into uppercase
437 $ut : it is used for to retrie(e reUuired fields and characters from a gi(en file
-&: madha( is good 2oy++1% chars
1ut 8f 2+ madha(+++o<p: adha
1ut 8c 1+1# madha(
1ut 8c +1#0 1+2# madha(+++++++for e(ery line +1#0 1+2# characters
447 Pa)te : is used for to Voin two or more files hori@ontally 2y using delimiter
9
MADHAV K
1at *states cat *cities paste 8d L:Mstates cities*tr
filename
J/ Gydera2ad J/: Gydera2ad
Tamilnadu madras Tamilnadu: madras
Warnataka Xangalore Warnataka: Xangalore
Werala Tri(andrum
.aharashtra Xom2ay
47 7ort : it is used for to sort the file content. Xy default it sorts file contents 2ased
on J)1II (alues+default is ascending
)ort sample
i7 sort 8r sample++++++displays descending order
ii7 sort 8u sample+++++it displays uniUue lines in the gi(en file
iii7 sort 8n file++++;4M numeric comparisons
i(7 sort 8nur file
(7 sort sample *temp
$m( temp sample
7orti!g the &ata iel& 83 iel&
,pos++starting field
+/os++ending field 6optional7
i7 )ort 8f ,pas1 8pas2 filename
ii7 )ort 8f ,1 +3 filename+++++starting from end 2efore 3
iii7 )ort 8fn ,2 +3 file ++++++it gi(es only num2ers
4!7 9!i: : it displays uniUue lines in the gi(en file 2ut the file contents should 2e in
sort order
-&:file1 i7 $ uniU file ii7 $uniU 8u filename++it eliminates duplicates
Jaaaaa
Jaaaaa Jaaaaa ccccc
Jaaaaa cccccccc ddddd
1cccccc dddddd /pppp
10
MADHAV K
"dddd hhhhhh ttttttt
Ghhhh pppppp
Ghhhh ttttttttt
/pppp
Ttttttt
iii7 $ PniU 8d filename++++displays only duplicated lines IE7 uniU 8c filename+++++it counts
how many times lines duplicated
Jaaaaa+++++2
1ccccccc++++1
E7 $ uniU 8u file *temp
$ m( temp filename
"elete duplicated lines from file "dddd+++++1
Ghhhhh+++2
/pppp+++++1
Ttttttt+++++1
4$7(i(i!g;.2 : it is used for to com2ine 2 or more cmds Stake left side o<p to right
side cmd as i<p
i7 $who Swc 8l+++++++++count total no of lines 6files7 in current directory
ii7 $ lsSwc 8l++++++++++++displays total no of su2directories in the current directory
iii7 ls 8l Sgrep LOdM++++displays total no of su2directories who stats with line no:d;
iE7 $head +3# sampleStail ,2# sample++++++display the the lines from 2# to 3# from
gi(en file
(7 $ grep P4I5 stud S cut 8f 20 3Ssort filename +++++display P4I5 students names & ph
no in ascending order
4%2 $tee : it is used to for to write data to the file as well as to the screen
$grep P4I5 stud S cut 8f 20 3 Ssort Stee file1
<=2 7hell )cri(ti!g'
It is group of P4I5 commands and shell keywords
11
MADHAV K
The main concept of shell scripting is to handle te&t files
I7 >ou!e )hell++++stea(e Xourne +++++$++++++++sh+++ 6sh as i!ter(reter2
ii2 >a)h )hell 62orne again shell7 +++same as a2o(e++ad(anced (ersion of Xourne is
XJ)G 6Dinu& default shell7
iii2 ?or! )hell++++++"a(id korn++++$++++++++++ksh 6interpreter7 ++++used as JI5 default
shell
.ostly used shell is korn shell it supports re usa2ility0 all shell designed on 2ourn shell
#2 $,)h : shift to korn shell
@17 $echo $0 : it displays current child shell name
@22 $alia) : it lists all alias names
@52 9!alia) alia) !a"e)' to delete alias names
@<2 $ hi)tor3 : it displays the pre(iously e&ecuted commands
@@2 Echo : it display the string on screen 6monitor7
0ile (er"i))io!)';xxxAxxxAxxx2
9)erAow!er+++(er"i))io!) ;ir)t (art2
Grou( (er"i))io!) ;)eco!& (art2
Other (er"i))io!) ;thir& (art2
B+++ ;a&& (er"i))io!) to uAgAo 8ut it &oe) !ot &elete exiti!g (er"i))io!2
+++ ;&e!3 (er"i))io!)2
C++++ ;a))ig! (er"i))io!) ;a&& (er"i))io!) to uAgAo 8ut it &elete exiti!g
(er"i))io!22
rw+<rw+<r++ +++++++++"efault permissions for regular files
rw&<rw&<r+&+++++++++default permission for directories
!7 ch"o& : it is used for to change file permissions
)yn: $chmod who< A,<+<YF<
i7 ls 8l filename+++++++rw+ rw+ rC
ii7 chmod g,& filename+++++rw+ rw& rC
iii7 chmod u,&0 g+w filename++++++rw& r+& rC
12
MADHAV K
iE7 chmod gYw filename+++++rw& 8w+ rC
Octal co&e
%ea&++++++<
Write+++++2
ExecuteD1
$chmod $! filename+++++++rw& r+& rw+
$chmod !42 filename++++rw+ r++ +w+
$7 chow! : to change owner name of the file
Zchown owner name filename
%2 chgre( : to change group name of the file
Z chgrp group name filename
%2 $write : it is user for to with the users 2ut the user should 2e logged into the ser(er
$write techno2 ii7 $mesg n++deny the msg
Gello iii7 mesg y+to allow msges
1mtl,d
'7 aw,A!aw, file : scan for patterns in a file and process the results
!#2 cat : concatenate 6list7 or file
!17 ch)h 6paawd 8e<+s7 userlogin[shell: change the user login shell
!27 & : report the summary of disk 2locks and nodes free and in use
i7 df 8k+++it displays the disk space in 2ytes
ii7 df 8h+++it displays disk space in kilo 2ytes
iii7 df 8g+++it displays the disk space in giga 2ytes
!37&u :it displays the directory wise disk usage in form of 2locks each 2lock si@e is 12
2ytes
!47g Ei( :to create a @ip file
-& $g@ip filename++++o<p: filename.g@
!7 gu!Ei( : to un@ip the files
13
MADHAV K
-&: gun@ip filename.g@
!!. co"(re)) : it also used for to @ip the file+++it used to sa(e with .@ format
!$7 9!co"(re)) : same as a2o(e
H@ip sa(es more memory than compress
!%7 Ecat : it used to displays @ip file contents in reada2le format
$@cat sample.g@
Kr
$@cat sample.@
!'7 To ,ill oregrou!& Fo8 c!tlBc or c!tlBE
$ sleep ##
1ntl,c
$ sleep 1##&
$#7 () or $ () / : it displays current user account running process list 6show status of
acti(e process7
$17 $() /a: it displays all user accounts running process list
$27 ?ill : it kill 2ackground process
-&: kill /I"
$37 tel!et : to connect to remote ser(er
$47 t(: file transfer protocol +++++transfer files from one ser(er to another
$ ftp ipaddress
Dogin: +++++++
/assword: ++++++
Btp*ls 6ser(er7
Btp*Sls6client7
Btp*get filename 6to download a file7
Btp*mget file1 file2+++++ 6to download multi files7
14
MADHAV K
Btp*put filename 6to upload a file7
Btp*mput file1 file2+++++ 6to upload multi files7
$70t(: to transfer files from one ser(er user account to another ser(er user account
$su root ++to switch to admin
$!7 Wall : it is used for to sent 2roadcast message to all users who are
currently working on ser(er
$wall
Gappy new+year
1ntl,d
$$7"ail :it is used for to send the mail0 if user is not logged in then also we can send
mail
i7 $ mail techno1
1ntl,d e(ery user contains mail2o&
at a time we can send msg to multiple users
27 $mail techno1 techno2 techno 3
)u2: from techno
1ntl,d
iii7 $ mail technoNstud
stud send content as a mail to techno3
mail is the cmd to read mails in the mail2o&
$mail
1*first mail
2*second mail reading
&2 it Uuickly opens second mail
&U++Uuit from mail 2o&
&w to sa(e mail contents to a file
&pprint mail contents
&r++replays
15
MADHAV K
&d+delete mails
$%2$"ail /:to read mails send to secondary mail2o&
$'7 e"ac) :full screen editor
%#2 echo : echo the te&t string to on monitor
%17 ile : classify the file type
%27 ex(r : e(aluates the arguments0 used to do arithmetic0etc in the shell
%37 i!& : find files0 matching a type or pattern
%47 Go)t!a"e : display or set the name of the current machine
%7l! : link the source to target
%!7l(:0l()tat :show the status of the print Vo2s
%$7l(rHl( :print to defind printer
%%7 l(r"H ca!cel : remo(e a print Vo2 from the print Uuee
%'7 "a! :display manual of gi(en cmd
=02o& :octal dump a 2inary file0in octal0J)1II0he&0decimal or char
'17(a))w& :to set or change password
'27 (r : filter the file and print it on the terminal
'37 rc( ho)t!a"e : remotely copy files from this machine to another machine
'47 rlogi!e ho)t!a"e: login remotely to another machine
'7 r)h ho)t!a"e : remote shell to run on another machine
'!7 )cri(t ile : sa(es e(erything that appears on the screen to file until e&it is
e&ecuted
'$7 )ource ile : read cmds from the file and e&ecute them in the current shell
'%7 )tri!g ile : used to search 2inary files for J)1II strings
''7 7t3 : set or display terminal control options
1##7 uu&eco&e ile : decode a uuencoded file0 recreating the original file
1#17 uue!co&e !ew !a"e : encode the 2inary file to $+2it J)1II0usefull when
sending (ia email0 to 2e "ecode as new name at destination
1#27 -i : (isual 0full screen editor
16
MADHAV K
1#37 Fo8) : display 2ackground and suspended processes
1#42 ,ill I1 : remo(e suspended process Z1
1#7 to( : display the current0 most computer+intensi(e commands
1#!7 o)-iew : display the operating system statistics
1#$7 )ete!- : list en(ironmental (aria2les
9N#J
What i) "ea!t 83 (a))w& ileK
This file maintains each and e(ery user information with $ fields. The $ fields are Psername:
passwd: uid: gid: fullname: home: shell.
What i) 7hellK
)hell is a command line interpreter. )hell acts as an interface 2etween user and the kernel.
What i) ?er!elK
Wernel is core part of P4I5 o<s. It is a group of hundreds of system calls.
What are &iere!t la-or) o 9!ix oA)K
Jny operating system designed 2ased on uni& kernel called as fla(our of uni&. The following
are some fla(ours of uni&
Dinu& ++++ ?ed Gat
)un solaris +++ )un .icrosystem
IX.+JI5 +++++ IX.
Gp+u& +++++ G/
)co+uni& +++++ santa crus operations
I?I5++++++ )ilicon Hraphics.
What are the &iere!t )ecurit3 eature) i! 9!ixK
1. /assword protection.
2. Bile permissions.
17
MADHAV K
3. -ncryption.
WhatL) the co""a!& to i!& out to&a3L) &ateK
date
WhatL) the co""a!& to i!& out u)er) o! the )3)te"K
who
Gow &o 3ou i!& out the curre!t &irector3 3ouLre i!K
pwd
What i) the co""a!& to )ee the locatio! o co""a!&K
Ihere is Ncommand name*
Gow &o 3ou i!& out 3our ow! u)er!a"eK
Ihoami 6or7 log name
Gow to clo)e the curre!t u)er accou!tK
-&it
Gow to create e"(t3 ileK
Touch Nfilename*
Gow &o 3ou re"o-e a ileK
?m Nfilename*
Gow to Foi! "ultiile ile) -erticall3K
1at file1 file2 file3 QQ
The ile or which we &o !ot ha-e write (er"i))io! ca! 8e &elete& u)i!g the
co""a!&K
rm +f Nfilename*
Gow &o 3ou re"o-e a &irector3 a!& it) )u8&irectorie)K
rm 8rf Ndirectoryname*
Gow to re!a"e a ileK
.( Nfilename*
Gow to co(3 "ulti(le ile) a!& &irectorie) i!to )o"e other &irector3K
cp +r source[directory destination[directory
Gow to )ee ho&&e! ile)K
18
MADHAV K
Ds 8a
Gow to )ee ile) a!& )u8&irectorie) ile) recur)i-el3K
Ds 8?
Gow to )ee ile) i! lo!g li)t or"at (age wi)eK
Ds 8l S more
Gow to i&e!ti3 whether a ile i) !or"al ile or &irector3K
$ls +l filename<directoryname
if the first digit is + then it is file0
if it is d then it is directory file
What i) the &iere!ce 8etwee! Ml) +rM a!& Ml) +%MK
ls +r lists the files in re(erse alpha2etical order... whereas ls +? lists the files and directories
recursi(ely
The &iere!ce 8etwee! a )ot li!, a!& a har& li!,K
J sym2olic 6soft7 linked file and the targeted file can 2e located on the same or different file
system while for a hard link they must 2e located on the same file system.
what are the &iere!t co""a!&) u)e& to create ile)K
1.touch + to create empty files 6e.g7 + touch Nfilename*
2.(i Nfilename*
3. cat*filename
Li)t )o"e wil& car& character)K
> + Iit matches any single character
9 + It matches @ero or more characters
AF + It matches any single character in gi(en list
. + It matches any single character e&cept enter key character
what i) the out(ut o the ollwi!g co""a!& ' l) Na+"!o+r4O
list all the files in the current directory starting alpha2et
19
MADHAV K
is 2etween a to m or n or 2etween o to r
Gow &o 3ou cou!t wor&)H li!e) a!& character) i! a ileK
Ic Nfilename*
which co""a!& i) u)e& to i&e!ti3 the t3(e o the ileK
file
Mgre(M "ea!)
Hlo2ally search a regular e&pression and print it
Gow &o 3ou )earch or a )tri!g i!)i&e a gi-e! ileK
grep string filename
Gow &o 3ou )earch or a )tri!g i!)i&e a curre!t &irector3K
grep string 9
Gow &o 3ou )earch or a )tri!g i! a &irector3 with the )u8&irectorie) recur)e&K
grep +r string 9
Diere!ce 8etwee! gre(H egre( a!& gre(
grep : does not accept more then one e&pression
egrep : accepts more than one pattern for search. Jlso accepts patterns from a file.
fgrep : accepts multiple patterns 2oth from command line and file 2ut does not accept
regular e&pressions only strings. It is faster than the other two and should 2e used when
using fi&ed strings.
What are li!e (atter!)K
O + start of the line
$ + -nd of the line
Gow to )earch e"(t3 li!e) i! a gi-e! ileK
Hrep LO$M Nfilename*
20
MADHAV K
Gow to cou!t !o o 8la!, li!e) i! a ileK
Hrep 8c LO$M Nfilename*
Gow to re"o-e E"(t3 li!e) or" a gi-e! ileK
Hrep 8( LO$M filename * temfilename
.( tempfilename filename
What i) (atter! to )earch < &igit wor& i! a ileK
Hrep LRNA#+'F A#+'F A#+'F A#+'FR*M filename
What i) (atter! to )earch the li!e ha-i!g o!l3 three character)K
Hrep LOP$Q filename
What i) (atter! to &i)(la3 li!e) e!&i!g with R$Q character i! a gi-e! ileK
Hrep LR$$M filename
Gow to &i)(la3 2 a!& < th ile&) ro" a gi-e! ile i the &eli"etr i) R'QK
1ut 8dM:M 8f 204 filename
Gow to &i)(la3 u!i:ue li!e) ro" a gi-e! ileK
)ort 8u filename
Gow to eli"i!ate co"(letel3 &u(licate li!e) ro" a gi-e! ileK
PniU 8u filename
Gow to re"o-e all &u(licate li!e) ro" a ileK
PniU 8u filename * tempfilename
.( tempfilename filename
Gow to &elete RhelloQ wor& ro" a gi-e! ileK
)ed Ls<hello<<M filename
awk $o""a!&
awk is a powful Pni& command. It allows the user to manipulate files that are structured as
columns of data and
Knce you understand the 2asics of awk you will find that it is surprisingly useful. 3ou can
use it to automate things in ways you ha(e ne(er thought a2out. It can 2e used for data
processing and for automating the application of Pni& commands. It also has many
spreadsheet+type functionalities.
21
MADHAV K
There are two ways to run awk. J simple awk command can 2e run from the command line.
.ore comple& tasks should 2e written as awk programs 6\scripts\7 to a file. -&amples of
each are pro(ided 2elow.
Exa"(le' ] awk ^pattern _action`^ input+file * output+file
meaning: take each line of the input filea if the line contains the pattern apply the action to
the line and write the resulting line to the output+file.
If the pattern is omitted0 the action is applied to all lines:
Gow to co"(are two ile) are )a"e or !otK
1mp
Gow to &i)(la3 the ir)t 10 li!e) ro" a ileK
Gead +1# filename
Write a o!e li!e co""a!& to co!-ert all the ca(ital letter) o a ile Mte)tM i!to
lower ca)eK
cat filename S tr \AJ+TF\ \Aa+@F\
The (i(eli!e to li)t the i-e large)t ile) i! the curre!t &irector3 i)
ls +l S tr +s ^ ^ S sort +t ^ ^ +fnr ,4 + S head 8
The (i(eli!e to i!& out the !u"8er o ti"e) the character K occur) i! the ile i)
tr +dc ^>^ N file S wc +c 6 "elete all the characters e&cept > and then make a word count.7
Gow to cou!t total !o. o u)er) wor,i!g i! the )3)te"K
Iho S wc 8l
Gow to &i)(la3 the li!e) ro" @ to 10 ro" a gi-e! ileK
Gead +1# filename S tail ,
what will 8e out(ut o ollowi!g co""a!&K
22
MADHAV K
echo RTec!o)otQ . wc /c
'
What i) the &eault u"a),K
#22
What i) the &eault (er"i))io! or 0ile S Director3 K
The "efault pri(ileges for file : !44
The default pri(ileges for directory : $
What 9N#J co""a!& will co!trol the &eault ile (er"i))io!) whe! ile) are
create&K
Pmask
Ex(lai! the rea&H writeH a!& execute (er"i))io!) o! a 9N#J &irector3.
?ead allows you to see and list the directory contents.
Irite allows you to create0 edit and delete files and su2directories in the directory.
-&ecute gi(es you the pre(ious read<write permissions plus allows you to change into the
directory and e&ecute programs or shells from the directory.
What i) ch"o&H chow! a!& chgr(K
1hmod : It is used for to change permissions on files
1hown : It is used for to change ownership of a file
1hgrp : It is used for to change group of the file
# the ow!er &oe)!Lt ha-e write (er"i))io! o! a ileH 8ut hi)Aher grou( ha)H ca!
heA)he e&it itK
4o. Ge<she can^t02ecause the owner^s permission o(errides the group^s.
To )ee li)t o ile) a!& &irectorie) Hwhat (er"i))io! re:uire&K
?ead permission
What are P#D)K
They are process I"s gi(en to processes. J /I" can (ary from # to !3.
Gow &o 3ou li)t curre!tl3 ru!!i!g (roce))K
ps
23
MADHAV K
Gow &o 3ou )to( a 8ac,grou!& (roce))K
kill pid
Gow &o 3ou i!& out a8out all ru!!i!g (roce))e)K
() +ag
Gow &o 3ou )to( all the (roce))e)H exce(t the )hell wi!&owK
kill #
Gow &o 3ou ire a (roce)) i! the 8ac,grou!&K
.A(roce))+!a"e S
What &oe) the co""a!& M,ill += $T M &oK
kills the last 2ackground process
i there i) a (roce)) u wa!t to ru! e-e! ater exiti!g the )hell what i) the
co""a!& u)e&K
4ohup
which co""a!& will get execute& e-e! ater 3ou log outK
4ohup
which )ig!al ca!!ot 8e tra((e&K
kill 8'
Gow to re&irect )ta!&ar& error to a ileK A!)wer
2* filename
What &oe) the to( co""a!& &i)(la3K
top command displays the current ammount of memory occupied
2y the currently e&ecuting processes and the details. In addition to memory usage top
command displays cpu usage and process details
What i) the co""a!& to )e!& "e))age to all u)er) who are logge& i!K
Iall
24
MADHAV K
What i) the co""a!& to )e!& "ail to other u)erK
.ail username
Gow to o(e! )eco!&ar3 "ail 8oxK
.ail +f
What &o 3ou &o i 3ou &o!Ut wa!t to 8e i!terru(te& 83 other u)er)U "e))age)K
Jns. mesg n
7hell 7cri(ti!g #!ter-iew :ue)tio!)
Diere!ce 8etwee! the out(ut o echo OO a!& echo O O
echo 99 lists all the filenames in the current directory..
echo 9 9 lists all the filenames in the current directory twice.
The other wa3 o ru!!i!g )hell )cri(t a(art ro" u)i!g )h co""a!& a!& ch"o&K
ans:+ using b we can run a shell script
1'. Gow do you refer to the arguments passed to a shell script> + $1H $2 a!& )o o!. $0 i)
3our )cri(t !a"e.
2#. Ihat;s the conditional statement in shell scripting> + i Vco!&itio!W the! P i
21. Gow do you do num2er comparison in shell scripts> + +e:H +!eH +ltH +leH +gtH +ge
22. Gow do you test for file properties in shell scripts> + +) ile!a"e tell) 3ou i the ile i)
!ot e"(t3H + ile!a"e tell) 3ou whether the argu"e!t i) a ileH a!& !ot a
&irector3H +& ile!a"e te)t) i the argu"e!t i) a &irector3H a!& !ot a ileH +w
ile!a"e te)t) or writea8ilit3H +r ile!a"e te)t) or rea&a8ilit3H +x ile!a"e te)t)
or executa8ilit3
23. Gow do you do Xoolean logic operators in shell scripting> + T te)t) or logical !otH +a
te)t) or logical a!&H a!& +o te)t) or logical or.
24. Gow do you find out the num2er of arguments passed to the shell script> + $X
2. Ihat;s a way to do multile(el if+else;s in shell scripting> + i Vco!&itio!W the!
V)tate"e!tW eli Vco!&itio!W V)tate"e!tW i
2!. Gow do you write a for loop in shell> + or V-aria8le !a"eW i! Vli)tW &o
V)tate"e!tW &o!e
2$. Gow do you write a while loop in shell> + while Vco!&itio!W &o V)tate"e!tW &o!e
2%. Gow does a case statement look in shell scripts> + ca)e V-aria8leW i! V(o))i8le+
-alue+1W2 V)tate"e!tWYY V(o))i8le+-alue+2W2 V)tate"e!tWYY e)ac
25
MADHAV K
2'. Gow do you read key2oard input in shell scripts> + rea& V-aria8le+!a"eW
3#. Gow do you define a function in a shell script> + u!ctio!+!a"e;2 V X)o"e co&e here
retur! W
31. Gow does getopts command work> + The parameters to your script can 2e passed as +n
1 +& 2#. Inside the script0 you can iterate through the getopts array as while getopts n:&
option0 and the (aria2le $option contains the (alue of the entered option.
Xatch file:
Xatch files allow .)+"K) and .icrosoft Iindows users to create a lists of commands to run
in seUuence once the 2atch file has 2een e&ecuted. Bor e&ample0 a 2atch file could 2e used
to run freUuently run commands0 deleting a series of files0 mo(ing files0 etc. J simple 2atch
file does not reUuire any special programming skills and can 2e done 2y users who ha(e a
2asic understanding of .)+"K) commands.
O%A$LE= i 0AZL)
1. IGJT I) "JTJ K? I4BK?.JTIK4>
Jns: The .atter that we feed into the 1omputer is called "ata or Information.
2. IGJT I) "JTJXJ)->
Jns: The 1ollection of Interrelated "ata is called "ata Xase.
3. IGJT I) J "JTJXJ)- .J4JH-.-4T )3)T-. 6"X.)7 /J1WJH->
Jns: The 1ollection of Interrelated "ata and some /rograms to access
the "ata is 1alled "ata Xase .anagement )ystem 6"X.)7.
4. IG-4 1J4 I- )J3 J "X.) /J1WJH- J) ?"X.)>
Jns: Bor a system to cualify as ?-DJTIK4JD "JTJXJ)- .J4JH-.-4T system0
it must use its ?-DJTIK4JD facilities to .J4JH- the "JTJXJ)-.
26
MADHAV K
. IGJT I) K?"X.)>
Jns: K2Vect 6oriented7 ?elational "ata Xase .anagement )ystem is one
that can store data0 the relationship of the data0 and the 2eha(ior of the data
6i.e.0 the way it interacts with other data7.
!. 4J.- )K.- 1K""^) ?PD-).
Jns: "r. -.B. 1odd presented 12 rules that a data2ase must o2ey if it
is to 2e considered truly relational. Kut those0 some are as follows
a7 The rules stem from a single rule+ the :@ero rule;: Bor a system to cualify as
?-DJTIK4JD "JTJXJ)- .J4JH-.-4T system0 it must use its ?-DJTIK4JD facilities
to .J4JH- the "JTJXJ)-.
27 Information ?ule: Ta2ular ?epresentation of Information.
c7 Huaranteed Jccess ?ule: PniUueness of tuples for guaranteed accessi2ility.
d7 .issing Information ?ule: )ystematic representation of missing information as 4PDD
Ealues.
e7 1omprehensi(e "ata )u2+Danguage ?ule: cD to support "ata definition0
Eiew definition0 "ata manipulation0 Integrity0 Juthori@ation and )ecurity.
$. IGJT J?- GI-?J?1GI1JD0 4-TIK?W0 J4" ?-DJTIK4JD "JTJXJ)- .K"-D)>
Jns: a7 Gierarchical Mo&el' The Gierarchical .odel was introduced in
the Information .anagement )ystem 6I.)7 de(eloped 2y IX. in 1'!%. In this data is
organi@ed as a tree structure. -ach tree is made of nodes and 2ranches.
The nodes of the tree represent the record types and it is a collection
of data attri2utes entity at that point. The topmost node in the structure is called the root.
4odes succeeding lower le(els are called children.
27 Networ, Mo&el' The 4etwork .odel0 also called as the 1K")3D data2ase
structure0 is an impro(ement o(er the Gierarchical mode0 in this model concept of parent
and child is e&panded to ha(e multiple parent+child relationships0 i.e. any child can 2e
su2ordinate to many different parents 6or nodes7. "ata is represented 2y
27
MADHAV K
collection of records0 and relationships among data are represented 2y
links. J link is an association 2etween precisely two records. .any+to+many relationships
can e&ists 2etween the parent and child.
c7 %elatio!al Mo&el' The ?elational "ata2ase .odel eliminates the need
for e&plicit parent+child relationships. In ?"X.)0 data is organi@ed in two+dimensional ta2les
consisting of relational0 i.e. no pointers are maintained 2etween ta2les.
%. IGJT I) "JTJ .K"-DI4H>
Jns: "ata .odeling descri2es relationship 2etween the data o2Vects. The
relationships 2etween the collections of data in a system may 2e graphically represented
using data modeling.
'. "-BI4- -4TIT30 JTT?IXPT- J4" ?-DJTIK4)GI/.
Jns: -ntity: Jn -ntity is a thing0 which can 2e easily identified. Jn entity is any o2Vect0
place0 person0 concept or acti(ity a2out which an enterprise records data.
Jttri2ute: Jn attri2ute is the property of a gi(en entity.
?elationship: ?elationship is an association among entities.
1#. IGJT I) -?+.K"-DI4H>
Jns: The -+? modeling techniUue is the Top "own Jpproach. -ntity
relationship is techniUue for analysis and logical modeling of a system;s data reUuirements.
It is the most widely used and has gained acceptance as the ideal data2ase design. It uses
three 2asic units: entities0 their attri2utes and the relationship that e&ists 2etween
the entities. It uses a graphical notation for representing these.
11. IGJT I) 4K?.JDITJTIK4>
Jns: 4ormali@ation is a step+2y+step decomposition of comple& records
28
MADHAV K
into simple records.
12. IGJT J?- EJ?IKP) 4K?.JD BK?.) KB "JTJ>
Jns: The Birst 4ormal Borm 14B0
The )econd 4ormal Borm 24B0
The Third 4ormal Borm 34B0
The Xoyce and 1odd 4ormal Borm X1 4B.
13. IGJT I) "-4K?.JDITJTIK4>
Jns: The intentional introduction of redundancy to a ta2le to impro(e
performance is called "-4K?.JDITJTIK4.
14. IGJT J?- 1+TI-?0 2+TI-?0 3+TI-? K? 4+TI-? "JTJXJ)- J?1GIT-1TP?-)>
Jns: 1+Tier "ata2ase Jrchitecture is 2ased on single system0 which acts
as 2oth ser(er and client.
2+Tier Jrchitecture is 2ased on one ser(er and client.
3+Tier Jrchitecture is 2ased on one ser(er and client out that on
client act as a remote system.
4+Tier Jrchitecture is 2ased on 4 no. Kf ser(ers and 4 no. Kf clients.
1. IGJT J?- J TJXD-0 1KDP.40 J4" ?-1K?">
Jns: Ta2le: J Ta2le is a data2ase o2Vect that holds your data. It is
made up of many columns. -ach of these columns has a data type associated with it.
1olumn: J column0 referred to as an attri2ute0 is similar to a field in
the file system.
?ecord: J row0 usually referred to as tuple0 is similar to record in
the file system.
29
MADHAV K
1!. IGJT I) "IBB-?-41- X-TI--4 J /?K1-"P?JD DJ4HPJH- J4" J
4K4+/?K1-"P?JD DJ4HPJH->
Jns:
/rocedural Danguage 4K4+/rocedural Danguage
J program in this implements a step+2y+step algorithm to sol(e the
pro2lem. It contains what to do 2ut not how to do .
1$.IGJT T3/- KB DJ4HPJH- \)cD\ I)>
Jns: )cD is a 4on+procedural0 4th generation Danguage0< which concerts
what to do rather than how to do any process.
1%. 1DJ))IBI1JTIK4 KB )cD 1K..J4")>
Jns:
""D 6"ata "efinition Danguage7 "cD A"ata cuerying Dnaguage F
".D 6"ata .anipulating Danguage7 "1D 6"ata 1ontrol Danguage7
T1D6"ata Transaction Danguage7
1reate Jlter "rop Truncate ?ename0 )elect 0 Insert Ppdate "elete .erge 0 Hrant ?e(oke 0
?oll2ack 1ommit sa(epoint

1'. IGJT I) "IBB-?-41- X-TI--4 ""D J4" ".D 1K..J4")>
Jns: Bor ""D commands autocommit is K4 implicitly whereas Bor ".D
commands autocommit is to 2e turned K4 e&plicitly.
30
MADHAV K
2#. IGJT I) "IBB-?-41- X-TI--4 J T?J4)J1TIK4 J4" J cP-?3>
Jns: J Transaction is unit of some commands where as cuery is a single
line reUuest for the information from the data2ase.
21. IGJT I) "IBB-?-41- X-TI--4 T?P41JT- J4" "-D-T- 1K..J4")>
Jns: Truncate 1ommand will delete all the records where as "elete
1ommand will delete specified or all the records depending only on the condition gi(en.
22. IGJT I) "IBB-?-41- X-TI--4 P/"JT- J4" JDT-? 1K..J4")>
Jns: Jlter command is used to modify the data2ase o2Vects where as the
Ppdate command is used to modify the (alues of a data 2ase o2Vects.
23. IGJT J?- 1K..J4") KB "1D 1JT-HK?3>
Jns: Hrant and ?e(oke are the two commands 2elong to the "1D 1ategory.

24. IGI1G I) J4 -BBI1I-4T 1K..J4" + T?P41JT- K? "-D-T-> IG3>
Jns: "elete is the efficient command 2ecause using this command we can
delete only those records that are not really reUuired.
2. IGJT J?- ?PD-) BK? 4J.I4H J TJXD- K? 1KDP.4>
Jns: 17 4ames must 2e from 1 to 3# 2ytes long.
27 4ames cannot contain Uuotation marks.
37 4ames are not case sensiti(e.
47 J name must 2egin with an alpha2etic character from your data2ase
character set and the characters $ and Z.
Xut these characters are discouraged.
7 J name cannot 2e K?J1D- reser(ed word.
31
MADHAV K
!7 J name must 2e uniUue across its namespace. K2Vects in the name
space must ha(e different names.
$7 J name can 2e enclosed in dou2le Uuotes.
2!. GKI .J43 1KDP.4) 1J4 J TJXD- GJE->
Jns: J Ta2le can ha(e 1### columns.
2$. IGJT J?- "IBB-?-4T "JTJT3/-) )P//K?T-" X3 )cD>
Jns: 1har 6si@e70 4char 6si@e70 Earchar2 6si@e70 4(archar2 6si@e7 data
types for character (alues0
4um2er 6precision0 scale70 4um2er0 4um2er 6n70 Bloat0 Bloat 62inary precision7 data types
for numerical (alues0 "ate data type for date (alues0
Dong0 ?aw 6si@e70 Dong ?aw0 1lo20 Xlo20 4clo20 Xfile for large o2Vects.
2%. IGJT I) "IBB-?-41- X-TI--4 DK4H J4" DKX "JTJT3/-)>
Jns:
DKX DK4H
17 The ma&imum si@e is 4HX.
27 DKXs 6e&cept 41DKX7 can 2e attri2utes of an o2Vect type.
37 DKXs support random access to data.
47 .ultiple DKX columns per ta2le or DKX attri2utes in an o2Vect type.
17 The ma&imum si@e is 2HX. 27 DK4Hs cannot. 37 DK4Hs support only
seUuential access.
47 Knly one DK4H column was allowed in a ta2le
32
MADHAV K
2'. IGJT I) "IBB-?-41- X-TI--4 1GJ? J4" EJ?1GJ?2 "JTJT3/-)>
Jns: Earchar2 is similar to 1har 2ut can store (aria2le no. Kf
characters and while Uuerying the ta2le (archar2 trims the e&tra spaces from the column
and fetches the rows that e&actly match the criteria.
3#. GKI .P1G .-.K?3 I) JDDK1JT-" BK? "JT- "JTJT3/-> IGJT I) "-BJPDT
"JT- BK?.JT I4 K?J1D->
Jns: Bor "ate data type oracle allocates $ 2ytes .emory.
"efault "ate Bormat is: ""+.K4+33.
31. IGJT I) ?J4H- BK? -J1G "JTJT3/- KB )cD>
Jns:
"atatype ?ange
1har Earchar2 4um2er Bloat DK4H0 ?JI0 DK4H?JI Darge K2Vects
6DKX;s7 2### 2ytes 4### 2ytes
/recision 1 to 3% )cale +%4 to 12$ /recision 3% decimals Kr 122 2inary
precision 2 HX 4HX
32. GKI TK ?-4J.- J 1KDP.4>
Jns: Ie can;t rename a 1olumn of a ta2le directly. )o we follow the
following steps.
To ?ename a 1olumn:
a7 Jlter the ta2le specifying new column name to 2e gi(en and data type.
27 Then copy the (alues in the column to 2e renamed into new column.
33
MADHAV K
c7 drop the old column.
33. GKI TK "-1?-J)- )IT- K? 1GJ4H- "JTJT3/- KB J 1KDP.4>
Jns: To "ecrease the si@e of a "ata type of a column
i. Truncate the ta2le first.
ii. Jlter the ta2le column whose si@e is to 2e decreased using the same
name and data type 2ut new si@e.
34. IGJT I) J 1K4)T?JI4T> IGJT J?- IT) EJ?IKP) D-E-D)>
Jns: 1onstraint: 1onstraints are representators of the column to
enforce data entity and consistency.There r two le(els
171olumn+le(el constraints 27Ta2le+le(el constraints.

3. DI)T KPT JDD TG- 1K4)T?JI4T) )P//K?T-" X3 )cD.
Jns: 4ot 4ull0 PniUue0 1heck0 /rimary Wey and Boreign Wey or ?eferential Integrity.
3!. IGJT I) "IBB-?-41- X-TI--4 P4IcP-,4KT 4PDD J4" /?I.J?3 W-3>
Jns: PniUue and 4ot 4ull is a com2ination of two 1onstraints that can 2e present any
num2er of times in a ta2le and can;t 2e a referential key to any column of an another ta2le
where as /rimary Wey is single 1onstraint that can 2e only once for ta2le and can 2e a
referential key to a column of another ta2le 2ecoming a referential integrity.
3$. IGJT I) J 1K./K)IT- /?I.J?3 W-3>
Jns: J /rimary key created on com2ination of columns is called 1omposite /rimary Wey.
3%. IGJT I) J 1J4"I"JT- 1KDP.4> GKI .J43 1J4"I"JT- 1KDP.4) 1J4 X-
/K))IXD- /-? 1K./K)IT- /?I.J?3 W-3>
Jns: It is a part of composite primary key. .a&imum 32 candidate key can 2e there in
composite primary key.
34
MADHAV K

3'. GKI TK "-BI4- J 4PDD EJDP->
Jns: J 4PDD (alue is something which is una(aila2le0 it is neither @ero
nor a space and any mathematical calculation with 4PDD is always 4PDD.
4#. IGJT I) 4PDD> J 1K4)T?JI4T K? "-BJPDT EJDP->
Jns: It is a default (alue.
41. IGJT I) "-BJPDT EJDP- BK? -E-?3 1KDP.4 KB J TJXD->
Jns: 4PDD.
42. IGJT I) 1?-JT-" I./DI1ITD3 BK? -E-?3 P4IcP- J4" /?I.J?3 W-3
1KDP.4)>
Jns: Inde&.
43. IGJT J?- DI.ITJTIK4) KB 1G-1W 1K4)T?JI4T>
Jns: In this we can^t specify /seudo 1olumns like sysdate etc.
44. IGJT I) "IBB-?-41- X-TI--4 ?-B-?-41-) J4" BK?-IH4 W-3 1K4)T?JI4T>
Jns: ?eferences is used as column le(el key word where as foreign key
is used as ta2le le(el constraint.
4. IGJT I) \K4 "-D-T- 1J)1J"-\>
35
MADHAV K
Jns: when this key word is included in the definition of a child ta2le
then whene(er the records from the parent ta2le is deleted automatically the respecti(e
(alues in the child ta2le will 2e deleted.
4!. IGJT I) /J?-4T+1GID" K? .J)T-?+"-TJID ?-DJTIK4)GI/>
Jns: J ta2le which references a column of another ta2le6using ?eferences7is called as a
child ta2le6detail ta2le7 and a ta2le which is 2eing referred is called /arent 6.aster7 Ta2le .
4$. GKI TK "?K/ J /J?-4T TJXD- IG-4 IT;) 1GID" TJXD- -5I)T)>
Jns: Psing \on delete cascade\.
4%. I) K?J1D- 1J)- )-4)ITIE->
Jns: 4K
4'. GKI K?J1D- I"-4TIBI-) -J1G ?-1K?" KB TJXD- P4IcP-D3>
Jns: Xy 1reating inde&es and reference I"s.
#. IGJT I) J /)-P"K+1KDP.4> 4J.- )K.- /)-P"K+1KDP.4) KB K?J1D->
Jns: 1olumns that are not created e&plicitly 2y the user and can 2e
used e&plicitly in Uueries are called /seudo+1olumns.
-&:curr(al0ne&t(al0sysdate0new0old0sUlcode0sUlerrm0rownum0rowid0le(el
1. IGJT BK? \K?"-? X3\ 1DJP)- BK? J cP-?3>
Jns: To arrange the Uuery result in a specified
Krder 6ascending0descending7 2y default it takes ascending order.
2. IGJT I) \H?KP/ X3\ cP-?I-)>
Jns: To group the Uuery results 2ased on condition.
36
MADHAV K
3. 4J.- )K.- JHH?-HJT- BP41TIK4) KB )cD>
Jns: JEH0 .J50 )P.0 .I401KP4T.
4. IGJT I) "IBB-?-41- X-TI--4 1KP4T 670 1KP4T 697 BP41TIK4)>
Jns: 1ount 67 will count the specified column whereas count 697 will
count total no. of rows in a ta2le.
. IGJT BK? ?KDDP/ J4" 1PX- K/-?JTK?) J?->
Jns: To get su2totals and grand total of (alues of a column.
!. IGJT I) J )PX+cP-?3>
Jns: J Uuery within a Uuery is called a su2 Uuery where the result of
inner Uuery will 2e used 2y the outer Uuery.
$. IGJT J?- )cD K/-?JTK?)>
Jns: Ealue 670 ?ef 67 is )cD operator. 6 Psed with K2Vects 7
%. -5/DJI4 \J43\0\)K.-\0\JDD\0\-5I)T)\ K/-?JTK?)>
Jns: A!3: The Jny 6or it;s synonym )K.-7 operator computes the lowest
(alue from the set and compares a (alue to each returned 2y a su2 Uuery.
All' JDD compares a (alue to e(ery (alue returned 2y )cD.
Exi)t)' This operator produces a XKKDIJ4 results. If a su2 Uuery
produces any result then it e(aluates it to T?P- else it e(aluates it to BJD)-.
37
MADHAV K
'. IGJT I) J 1K??-DJT-" )PX cP-?30 GKI IT I) "IBB-?-4T B?K. J 4K?.JD
)PX cP-?3>
Jns: J correlated su2Uuery is a nested su2Uuery0 which is e&ecuted once
for each :1andidate row; 2y the main Uuery0 which on e&ecution uses a (alue from a column
in the outer Uuery. In normal su2 Uuery the result of inner Uuery is dynamically su2stituted
in the condition of the outer Uuery where as in a correlated su2Uuery0 the column
(alue used in inner Uuery refers to the column (alue present in the
outer Uuery forming a correlated su2Uuery.
!#. IGJT I) J dKI4 + T3/-) KB dKI4)>
Jns: J Voin is used to com2ine two or more ta2les logically to get
Uuery results.
There are four types of doins namely
-cPI doin
4K4+-cPI doin
)-DB doin
KPT-? doin.
!1. IGJT J?- .I4I.P. ?-cPI?-.-4T) BK? J4 -cPI+dKI4>
Jns: There shold 2e atleast one common column 2etween the Voining ta2les.
!2. IGJT I) "IBB-?-41- X-TI--4 D-BT0 ?IHGT KPT-? dKI4>
Jns:If there r any (alues in one ta2le that do not ha(e corresponding (alues in the other0in
an eUui Voin that row will not 2e selected.)uch rows can 2e forcefully selected 2y using outer
Voin sym2ol6,7 on either of the sides6left or right7 2ased on the reUuirement.
!3. IGJT I) "IBB-?-41- X-TI--4 -cPI J4" )-DB dKI4)>
Jns: )-DB dKI4 is made within the ta2le whereas
38
MADHAV K
-cPI dKI4 is made 2etween different ta2les ha(ing common column.
!4. IGJT J?- \)-T\ K/-?JTK?)>
Jns: P4IK4 JDD0P4IK40 I4T-?)-1T 0.I4P) are )-T K/-?JTK?).
!. IGJT I) "IBB-?-41- X-TI--4 \P4IK4\ J4" \P4IK4 JDD\
K/-?JTK?)>
Jns: P4IK4 will return the (alues distinctly whereas P4IK4 JDD will
return e(en duplicate (alues.
!!. 4J.- )K.- 4P.X-?0 1GJ?J1T-?0 "JT-0 1K4E-?)IK40 KTG-?
BP41TIK4).
Jns: Nu"8er 0u!ctio!)'
?ound 6m0 AnF70 Trunc 6m0 AnF70 /ower 6m0 n70 )Urt6n70
J2s 6m70 1eil 6m70 Bloor 6m70 .od 6m0 n7 0sign6n7
$haracter 0u!ctio!)'
1hr 6&70 1oncat 6string10 string270 Dower 6string7
Ppper 6string70 )u2str 6string0 from[str0 to[str70 J)1II 6string7
Dength 6string70 Initcap 6string7.

Date 0u!ctio!):
)ysdate0 .onths 2etween 6d10 d270 To[char 6d0 format7
Dast day 6d70 4e&t[day 6d0 day7.add[months6d0n70 -&tract
$o!-er)io! 0u!ctio!)' To[char0 To[date0 To[num2er
39
MADHAV K
!$. IGJT I) "IBB-?-41- X-TI--4 .J5 67 J4" H?-JT-)T 67 BP41TIK4)>
Jns: .J5 is an aggregate function which takes only one column name of a ta2le as
parameter whereas Hreatest is a general function which can take any num2er of (alues and
column names from dual and ta2le respecti(ely.
!%. IGJT BK? 4ED 67 BP41TIK4 I)>
Jns: 4ED Bunction helps in su2stituting a (alue in place of a 4PDD.
!'. IGJT BK? "-1K"- 67 BP41TIK4 I)>
Jns: It is su2stitutes (alue 2asis and it actually does an
^if+then+else^ test.
$#. IGJT I) "IBB-?-41- X-TI--4 T?J4)DJT- 67 J4" ?-/DJ1- 67 BP41TIK4)>
Jns: Translate67 is a superset of functionality pro(ided 2y ?eplace67.
$1. IGJT I) "IBB-?-41- X-TI--4 )PX)T? 67 J4" I4)T? 67 BP41TIK4)>
Jns: )u2str67 will return the specified part of a string whereas

Instr67 return the position of the specified part of the string.
$2. IGJT I) J dPDIJ4 "J3 4P.X-?>
Jns: It will return count of the no. Kf days 2etween danuary 10 4$12 X1
and the gi(en date.
$3. GKI TK "I)/DJ3 TI.- B?K. J "JT- "JTJ>
Jns: Xy using time format as ^hh Ahh24F: mi: ss^ in to[char67 function.
40
MADHAV K
$4. GKI TK I4)-?T "JT- J4" TI.- I4TK J "JT- 1KDP.4>
Jns: Xy using format ^dd+mon+yy hh Ahh24F: mi: ss^ in to[date67 function.
$. IGJT I) "IBB-?-41- X-TI--4 TK["JT- 67 J4" TK[1GJ? 67 1K4E-?)IK4
BP41TIK4)>
Jns: To[date con(erts character date to date format whereas
To[char function con(erts date or numerical (alues to characters.
$!. IGJT I) J EI-I> GKI IT I) "IBB-?-4T B?K. J TJXD->
Jns: Eiew is data2ase o2Vect0 which e&ists logically 2ut contains no
physical data and manipulates the 2ase ta2le.
Eiew is sa(ed as a select statement in the data2ase and contains no
physical data whereas Ta2le e&ists physically.
$$. IGJT I) "IBB-?-41- X-TI--4 )I./D- J4" 1K./D-5 EI-I)>
Jns: )imple (iews can 2e modified whereas 1omple& (iews 6created 2ased
on more than one ta2le7 cannot 2e modified.
$%. IGJT I) J4 I4DI4- EI-I>
Jns: Inline (iew is 2asically a su2Uuery with an alias that u can use
like a (iew inside a )cD statement. It is not a schema o2Vect like )cD+o2Vect.
$'. GKI TK P/"JT- J 1K./D-5 EI-I>
Jns: Psing ^I4)T-J" KB^ T?IHH-?) 1omple& (iews can 2e Ppdated.
%#. IGJT BK? \IITG 1G-1W K/TIK4\ BK? J EI-I>
41
MADHAV K
Jns: \IITG 1G-1W K/TIK4\ clause specifies that inserts and updates r performed through
the (iew r not allowed to create rows which the (iew cannot select and therefore allows
integrity constraints and data (alidation checks to 2e enforced on data 2eing inserted or
updated.
%1. IGJT I) J4 I4"-5> J"EJ4TJH- KB J4 I4"-5
Jns: Jn Inde& is a data2ase o2Vect used n Kracle to pro(ide Uuick
access to rows in a ta2le. Jn Inde& increases the performance of the data2ase.
%2. IGJT I) J )-cP-41-> /)-P"K+1KDP.4) J))K1IJT-" IITG )-cP-41->
Jns: )eUuence is a "ata2ase K2Vect used to generate uniUue integers to use as primary
keys. 4e&t(al0 1urr(al are the /seudo 1olumns associated with the seUuence.
99%3. IGJT I) J 1DP)T-?> IG-4 TK P)- J 1DP)T-?> GKI TK "?K/ J 1DP)T-?
IG-4 1DP)T-?-" TJXD- -5I)T)>
Jns: 1luster and Inde&es are transparent to the user. 1lustering is a
method of storing ta2les that are intimately related and are often Voined together into the
same area on the disk.
Ihen cluster ta2le e&ists then to drop cluster we ha(e to drop the ta2le first then only
cluster is to 2e dropped.
%4. IGJT I) J )4J/)GKT K? .JT-?IJDIT-" EI-I>
Jns: .ateriali@ed (iews can 2e used to replicate data. -arlier the data
was replicated through 1?-JT- )4J/)GKT command. 4ow 1?-JT- .JT-?IJDIT-" EI-I
can 2e used as synonym for 1?-JT- )4J/)GKT. cuery performance is impro(ed using the
materiali@ed (iew as these (iews pre calculate e&pensi(e Voins and aggregate operations on
the ta2le.
%. IGJT I) J )34K43.>
Jns: J )ynonym is a data2ase o2Vect that allows you to create alternate names for Kracle
ta2les and (iews. It is an alias for a ta2le0 (iew0 snapshot0 seUuence0 procedure0 function or
42
MADHAV K
package.
%!. IGJT I) "IBB-?-41- X-TI--4 /?IEJT- J4" /PXDI1 )34K43.>
Jns: Knly the user or ta2le owner can reference /ri(ate synonym whereas
any user can reference the /u2lic synonym.
%$. IGJT I) "IBB-?-41- X-TI--4 \)cD\ J4" \)cD9/DP)\ 1K..J4")>
Jns: )cD commands are stored in the 2uffer whereas )cD9/DP) are not.
99%%. 4J.- )K.- )cD9/DP) 1K..J4")>
Jns: "-)1 A1?IX-F0 )TJ?T0 H-T0 )JE-0 < are )cD9/DP) 1K..J4").
%'. IGJT J?- \)cD9/DP) ?-/K?TI4H\ 1K..J4")>
Jns: )/KKD file+name0 )/KKD KBB0 TTITD-0 XTITD-0 X?-JW K40 1K./PT- Nany
aggregate function* KB Ncolumn name* A2reakF K4 Ncolumn name* etc are )cD9/DP)
?-/K?TI4H 1K..J4").
'#. IGJT J?- )3)T-. J4" KXd-1T /?IEID-H-)>
Jns: 1onnect and ?esource etc are )ystem /ri(ileges.
1reate No2Vect*0 )elect0 Insert0 Jlter etc are K2Vect /ri(ileges.
'1. IGJT BK? "1D 1K..J4") J?->
Jns: 1ommit0 ?oll2ack are "1D commands.
'2. IGJT BK? H?J4T 1K..J4" IITG \IITG H?J4T K/TIK4\>
Jns: LIith Hrant KptionM with Hrant 1ommand gi(es pri(ileges to the
user to grant pri(ileges to other user6s7
43
MADHAV K
among the pri(ileges he<she has.
'3. GKI TK 1GJ4H- /J))IK?" KB J P)-?>
Jns: Psing /assword command or
Psing JDT-? P)-? Nuser name* I"-4TIBI-" X3 Nnew password* 1K.J4".
'4. IGJT I) J )1G-.J J4" )1G-.J KXd-1T)>
Jns: J schema is a collection of logical structures of data0 or schema
o2Vects. J schema is owned 2y the data2ase user and has the same name as that of user.
-ach user owns a single schema. )chema o2Vects include following
type of o2Vects 1lusters0 "ata2ase Dinks0 Bunctions0 Inde&es0 /ackages0
/rocedures0 )eUuences0 )ynonyms0 Ta2les0 "ata2ase Triggers0 Eiews.
99'. GKI TK )TJ?TP/ J4" )GPT"KI4 K?J1D- "JTJXJ)->
Jns: )tartup and )hutdown Kracle data2ase can 2e done 2y only the
administator. )tartup is done 2y using )TJ?TP/ command and )hutdown is done 2y
)GPT"KI4 command
'!. IGJT I) J )-))IK4>
Jns: The period 2etween Dogin and Dogoff on schema.
'$. IGJT I) J 1DI-4T /?K1-))> IGJT I) J )-?E-? /?K1-))>
Jns: ref: 1$2 c & J.
'%. GKI TK .JW- -E-?3 ".D K/-?JTIK4 J) JPTK 1K..IT>
Jns: Xy using )-T JPTK1K..IT K4 command.
44
MADHAV K
''. GKI TK "I)/DJ3 "JTJ /JH- II)- I4 )cD>
Jns: Xy using )-T /JP)- K4 command.
1##. GKI TK 1GJ4H- DI4- )IT-0 /JH- )IT- J4" )cD /?K./T>
Jns: Xy using )-T DI4-)IT- N(alue*0 )-T /JH-)IT- N(alue*0
)-T )cD/?K./T Nnew prompt*.
1#1. GKI /D<)cD I) "IBB-?-4T B?K. )cD>
Jns: )cD is non+procedural language whereas /D<)cD is procedural
language that includes features and design of programming language.
1#2. IGJT I) J?1GIT-1TP?- KB /D<)cD>
Jns: Hi(e picture & -&plain
1#3. IGJT I) J /D<)cD XDK1W>
Jns: "-1DJ?-
Ndeclarations*
X-HI4
N-&ececuta2le )tatements*
-51-/TIK4
N-&ception Gandler6s7*
-4"a
1#4. IGJT J?- "IBB-?-4T T3/-) KB /D<)cD XDK1W)>
Jns: "-1DJ?- XDK1W: In this 2lock all the declarations of the (aria2le
used in the program is made. If no (aria2les are used this 2lock will 2ecome optional.
45
MADHAV K
X-HI4 XDK1W: In this 2lock all the e&ecuta2le statements are
placed. This 2lock is .andatory.
-51-/TIK4 XDK1W: In this 2lock all the e&ceptions are handled.
This 2lock is also (ery optional.
-4": -(ery 2egin must 2e ended with this -4"a statement.
A!o!3"ou) S Na"e& >loc,)
1#. IGJT J?- 1K./K)IT- "JTJ T3/-)>
Jns: ?ecords0 Ta2les are two 1omposite data types.
1#!. IGJT I) )1K/- KB J EJ?IJXD- I4 /D<)cD XDK1W>
Jns: The (isua2ility and accessi2ility of a (aria2le within the
2lock6s7 is called scope of a (aria2le.
1#$. IGJT I) J 4-)T-" XDK1W>
Jns: J 2lock within a 2lock is called 4ested Xlock.
1#%. IGJT I) J /D<)cD -4HI4->
Jns: The /D<)cD engine accepts any (alid /D<)cD 2lock as input0 e&ecutes the procedural
part of the statements and sends the )cD statements to the )cD statement e&ecutor in the
Kracle ser(er.
1#'. IGJT I) "-BJPDT EJDP- BK? J 4P.-?I1 /D<)cD EJ?IJXD->
Jns: 4PDD
11#. IGJT I) "IBB-?-41- X-TI--4 )I./D- DKK/ J4" J BK? DKK/>
Jns: )imple reUuires declaration of (aria2les used in it and e&it
46
MADHAV K
condition 2ut Bor Doop doesn;t reUuire this.
111. IGJT I) J 1P?)K?> )T-/) TK P)- J 1P?)K?>
Jns: 1ursor is /ri(ate )cD area in /D<)cD.
"eclare the 1ursor0
Kpen the 1ursor0
Betch (alues from )cD into the local Earia2les0
1lose the 1ursor.
112. GKI .J43 T3/-) KB 1P?)K?) J?- )P//K?T-" X3 K?J1D->
Jns: There are two types of cursors namely Implicit 1ursor0 -&plicit 1ursor.
113. IGJT I) J 1P?)K? BK? DKK/>
Jns: 1ursor Bor Doop is shortcut process for -&plicit 1ursors 2ecause
the 1ursor is Kpen0 ?ows are fetched once for each iteration and the cursor is closed
automatically when all the rows ha(e 2een processed.
114. IGJT J?- 1P?)K? JTT?IXPT-)>
Jns: ]Bound
]4otBound
]IsKpen
]?ow1ount are the cursor attri2utes.
11. IGJT I) P)- KB 1P?)K? IITG \BK? P/"JT- KB\ 1DJP)->
Jns: This 1lause stop accessing of other users on the particular
columns used 2y the cursor until the 1K..IT is issued.
47
MADHAV K
11!. IGJT I) J4 -51-/TIK4> GKI IT I) "IBB-?-4T B?K. -??K?>
Jns: Ihene(er an error occurs -&ception raises. -rror is a 2ug whereas the -&ception is a
warning or error condition.
11$. 4J.- )K.- XPIDT+I4 -51-/TIK4).
Jns: Too[.any[?ows0 4o["ata[Bound0 Tero["i(ide0 4ot[Dogged[Kn
)torage[-rror0 Ealue[-rror etc.
11%. GKI TK 1?-JT- J P)-?+"-BI4-" -51-/TIK4>
Jns: Pser+"efined -&ception is created as follows:
"-1DJ?-
Ne&ception name* -51-/TIK4a
+ + + + + + + + + a
+ + + + + + + + +a
X-HI4
+ + + + + + + + +a
+ + + + + + + + +a
?JI)- Ne&ception name*a
-51-/TIK4
IG-4 Ne&ception name* TG-4
+ + + + + + + + +a
+ + + + + + + + +a
-4"a
11'. IGJT I) \KTG-?)\ -51-/TIK4>
48
MADHAV K
Jns: It is used to along with one or more e&ception handlers.
This will handle all the errors not already handled in the 2lock.
12#. IGJT I) )1K/- KB -51-/TIK4 GJ4"DI4H I4 4-)T-" XDK1W)>
Jns: -&ception scope will 2e with in that 2lock in which e&ception
handler is written.
121. IGJT I) J )PX+/?KH?J.>
Jns: J )PX/?KH?J. I) J /D<)cD XDK1W0 IGI1G IIDD X- I4EKW-" X3 TJWI4H
/J?J.JT-?).
122. IGJT J?- "IBB-?-4T T3/-) KB )PX+/?KH?J.)>
Jns: TG-3 ? TIK T3/-): 17 /?K1-"P?- 27 BP41IK4.
123. GKI J /?K1-"P?- I) "IBB-?-4T B?K. J BP41TIK4>
Jns: Bunction has return key word and returns a (alue whereas a
/rocedure doesn;t return any (alue.
124. IGJT J?- T3/-) KB /J?J.-T-?) TGJT 1J4 X- /J))-" TK BP41TIK4 K?
/?K1-"P?->
Jns: I40 I4 KPT0 KPT.
12. IGJT I) \I4 KPT\ /J?J.-T-?>
Jns: J parameter0 which gets (alue into the /rocedure or Bunction and
takes the (alue out of the /rocedure or
Bunction area0 is called I4 KPT parameter.
49
MADHAV K
12!. "K-) K?J1D- )P//K?T) /?K1-"P?- KE-?DKJ"I4H>
Jns: 4K.
12$. IGJT I) J /J1WJH- J4" /J1WJH- XK"3>
Jns: /ackage is declarati(e part of the functions and procedures stored
in that package and package 2ody is
the definition part of the functions and procedures of that package.
12%. IGJT I) J"EJ4TJH- KB /J1WJH- KE-? /?K1-"P?- K? BP41TIK4>
Jns: /ackages pro(ides Bunctions or /rocedures K(erloading facility and
security to those Bunctions or
/rocedures.
12'. I) IT /K))IXD- TK GJE- J /?K1-"P?- J4" J BP41TIK4 IITG TG- )J.-
4J.->
Jns: 4K if it is out side a /ackage0 3-) if it is within a /ackage.
13#. "K-) K?J1D- )P//K?T) ?-1P?)IE- BP41TIK4 1JDD)>
Jns: 3-).
131. IGJT I) J T?IHH-?> GKI IT I) "IBB-?-4T B?K. J /?K1-"P?->
Jns: Trigger: J Trigger is a stored /D<)cD program unit associated
with a specific data2ase ta2le.
/rocedure: J /rocedure is to 2e e&plicitly called 2y the user
whereas Triggers are automatically called implicitly
2y Kracle itself whene(er e(ent Kccurs.
50
MADHAV K
132. IGJT I) "IBB-?-41- X-TI--4 J T?IHH-? J4" J 1K4)T?JI4T>
Jns: 1onstraints are always T?P- whereas Triggers are 4KT always T?P-
and 1onstraints has some limitations whereas Trigger has no limitations.
133. IGJT J?- "IBB-?-4T -E-4T) BK? J T?IHH-? J4" TG-I? )1K/-)>
Jns: Insert0 Ppdate or "elete.
134. IGJT I) "IBB-?-41- X-TI--4 TJXD- D-E-D J4" ?KI D-E-D T?IHH-?)>
Jns: Ta2le le(el Triggers e&ecute once for each ta2le 2ased transaction
whereas ?ow le(el Triggers will e&ecute once BK? -J1G ?KI.
99 13. IGJT J?- JPTK4K.KP) T?IHH-?)>
Jns: )upports to pro(ide 1ommit statement in Triggers. Triggers a declared as independent
Transactions.
13!. IGJT I) J4 \I4)T-J" KB\ T?IHH-?>
Jns: These Triggers are used with the 1omple& Eiews only to make
possi2le of Insert0 Ppdate and "elete on those Eiews.
99 13$. GKI .J43 T?IHH-?) 1J4 X- 1K4BIHP?-" K4 J TJXD- J4" EI-I>
Jns: 1% Triggers
13%. IGJT I) \TJXD- .PTJTI4H\ -??K?> GKI TK )KDE- IT>
Jns: K?J+#4#'1: Ta2le name is mutating0 trigger<function may not see it
51
MADHAV K
1ause : J trigger or a user+defined /D<)cD function that is referenced
in the statement attempted to Uuery or modify a ta2le that was in the middle of 2eing
modified 2y the statement that fired the trigger.
Jction : ?ewrite the trigger or function so it does not read the ta2le.
13'. IG-4 TK P)- \:4-I\ J4" \:KD"\ )/-1IBI-?)>
Jns: The prefi& :old is used to refer to (alues already present in the
ta2le. The prefi& :new is a correlation name that refers to the new (alue that is inserted <
updated.
99 141. GKI TK 1?-JT- J P)-?+"-BI4-" EJ?IJXD- I4 /D<)cD>
Jns: "efine (aria2le in declaration section
142. GKI TK 1?-JT- J4 J??J3 EJ?IJXD- I4 /D<)cD>
Jns: Psing 1?-JT- AK? ?-/DJ1-F T3/- Ntype name*
J) EJ??J3 6si@e7 KB -D-.-4T[T3/- 64KT 4PDD7 1ommanda
99143. GKI TK .JW- J P)-?+"-BI4-" "JTJ T3/- HDKXJD I4 /D<)cD>
Jns: "eclare the (aria2le in a /ackage
144. GKI TK 1?-JT- J4 KXd-1T I4 K?J1D->
Jns: Psing 1?-JT- AK? ?-/DJ1-F T3/- Ntype name* J) KXd-1T 6JTT?IXPT-
4J.- "JTJ T3/-0..7 1ommand
14. IGJT I) J T?J4)I-4T J4" /-?)I)T-4T KXd-1T>
Jns: The K2Vect created in a ta2le is called /ersistent K2Vect.
K2Vect created on e&ecution of /D<)cD 2lock is called Transient K2Vect.
52
MADHAV K
9914!. IGJT I) J 1KDP.4 KXd-1T J4" TJXD- KXd-1T>
Jns: J 1olumn K2Vect is only a 1olumn of a ta2le.

14$. GKI TK H?J4T /-?.I))IK4 K4 J4 KXd-1T TK KTG-? P)-?>
Jns: H?J4T Npermission* K4 No2Vect name* TK Nuser name*.
14%. IGJT I) J 1KDD-1TIK4 KB K?J1D->
Jns: Earray0 4ested Ta2le is a collection of Kracle.
14'. IGJT I) "IBB-?-41- X-TI--4 EJ??J3 J4" 4-)T-" TJXD->
Jns: Earray has a fi&ed si@e.
4ested ta2les can carry any num2er of (alues.
1#. GKI TK .K"IB3 1K4T-4T) KB J EJ??J3 I4 K?J1D->
Jns: To modify a stored EJ??J3 it has to selected into a
/D<)cD (aria2le and then inserted 2ack into the ta2le.
11. IGJT I) P)- KB \TG-\ K/-?JTK? BK? 4-)T-" TJXD->
Jns: TG- operator allows nested ta2les to 2e manipulated using ".D when
it is stored in a Ta2le.
12. IGI1G /J1WJH- I) P)-" BK? BID- I4/PT<KPT/PT I4 K?J1D->
Jns: PTD[BID- /ackage is used for Bile input<output in Kracle.
53
MADHAV K
13. 4J.- )K.- .-TGK") J4" /?K1-"P?-) KB BID- I<K /J1WJH->
Jns: BK/-40 B1DK)-0 BBDP)G0 I)[K/-40 H-T[DI4-0 /PT[DI4-0 /PTB0 4-I[DI4-

9914. IGJT I) )cDd> GKI IT I) "IBB-?-4T B?K. d"X1 1K44-1TIEIT3>
Jns: )cDd is 2asically a da(a program containing em2edded static )cD
statements that are compati2le with da(a design philosophy.
1. IGJT I) J4 IT-?JTK?> 4ame some T3/-) KB IT-?JTK?)>
Jns: )cDd Iterators are 2asically record groups generated during
transaction0 which reUuires manipulation of more than one records from one or more ta2les.
There are two types Iterators namely 4amed Iterator and /ositional Iterator.
99 1!. IGJT J?- "IBB-?-4T )T-/) TK I?IT- J "34J.I1 )cD /?KH?J.>
Jns: -g: char c[sUlstringAFY_L"-D-T- B?K. sailors IG-?- rating*M`a
-5-1 )cD /?-/J?- readytogo B?K. :c[sUlstringa
-5-1 )cD -5-1PT- readytogoa
1$. IGJT I) TJXD- /J?TITIK4I4H J4" I4"-5 /J?TITIK4I4H>
Jns: Kracle% allows ta2les and Inde&es to 2e partitioned or 2roken up into smaller parts
2ased on range of key (alues. /artitioning is a Ldi(ide and conUuerM strategy that impro(es
administration and performance in data warehouse and KDT/ systems.
1'. IGJT I) /G3)I1JD .-.K?3 )T?P1TP?- KB K?J1D->
Jns: The 2asic oracle memory structure associated with Kracle includes:
)oftware 1ode Jreas The )ystem Hlo2al Jrea 6)HJ7 0The "ata2ase Xuffer 1ache
The shared /ool0 The /rogram Hlo2al Jreas 6/HJ70 )tack Jreas 0"ata Jreas0 )ort Jreas
1!#. IGJT I) DKHI1JD .-.K?3 )T?P1TP?- KB K?J1D->
54
MADHAV K
Jns: "ata2ase0 Ta2lespace 0 "X K2Vect0 )egment0 -&tents
1!1. IGJT I) 7GA>
Jns: J )ystem Hlo2al Jrea is a group of shared memory allocated 2y
Kracle that contains data and control information for one Kracle data2ase instance. IB the
multiple users are concurrently connected to the same instance0 the data in the instance;s
)HJ is LsharedM among the users.
1onseUuently0 the )HJ is often referred to as either the Lsystem Hlo2al JreaM or the
L)hared
Hlo2al JreaM.
1!2. IGJT I) PGA>
Jns: The /rogram Hlo2al Jrea is a memory 2uffer that contains data and
control information for a ser(er process. J /HJ is created 2y Kracle when a ser(er process
is started. The information in a /HJ depends on the configuration of Kracle.
1!3. IGJT I) J4 K?J1D- I4)TJ41->
Jns: -(ery time a data2ase is started0 an )HJ is allocated and Kracle
2ackground processes are started. The com2ination of these processes and memory 2uffers
is called an Kracle instance.
1!4. IGJT J?- "IBB-?-4T K?J1D- /?K1-))-)>
Jns: J process is a Lthread of controlM or a mechanism in an operating
system that can 2e e&ecute a series of steps. )ome operating systems use terms Vo2s or
task. J process normally has its own pri(ate memory area in which it runs. Jn Kracle
data2ase system has general types of process: Pser /rocesses and Kracle /rocesses.
991!. IGJT I) "IBB-?-41- X-TI--4 /.K4 J4" ).K4>
Jns: ).K4 6)ystem .onitor7 performs instance reco(ery at instance of
55
MADHAV K
startup. In a multiple instance system 6one that uses the parallel ser(er70 ).K4 of one
instance can also perform instance reco(ery other instance that ha(e failed whereas The
/.K4 6/rocess .onitor7 performs process reco(ery when a user process fails.
991!!. IGJT I) "IBB-?-41- X-TI--4 "JTJXJ)- J4" TJXD-)/J1->
Jns: "ata2ase is a physical 1omponent
Ta2lespace is a Dogical component
1!$. IGJT I) dKX KB "JTJXJ)- I?IT-? 6"XI?7 /?K1-))>
Jns: The "ata Xase Iriter writes modified 2locks from the data2ase
2uffer cache to the data files.
1!%. IGJT I) dKX KB DKH I?IT-? 6DHI?7 /?K19))>
Jns: The Dog Iriter writes redo log files to disk. ?edo log data is
generated in the redo log 2uffer of the )HJ. Js transactions commit and log 2uffer fills0
DHI? writes redo entries into an online redo log file.
1!'. IGJT I) ?-1KE-?-?>
Jns: The ?eco(er 6?-1K7 is used to resol(e distri2uted transactions that are pending due to
network or system failure in a distri2uted data2ase. Jt timed inter(als0 the local ?-1K
attempts to concept to remote data2ase and automatically complete the commit or roll2ack
of the local portion of any pending distri2uted transactions.
1$#. IGJT I) J?1GIE-?>
Jns: The Jrchi(er 6J?1G7 copies the online redo log files to archi(al storage when they are
full. 0J?1G is acti(e only when a data2ase;s redo log is used J?1GIDKH mode.
99 1$1. IGJT I) J )TK?-" cP-?3>
Jns: EI-I
56
MADHAV K
1$2. IGJT I) P)-? /?K1-)) J4" )-?E-? /?K1-))>
Jns: J Pser process is created and maintained to e&ecute the software
code of an application program 6such as /?K 9 /rogram7 or an K?J1D- tool 6such as )cD 9
"XJ7. The Pser process also manages the communication
with ser(er processes. Pser processes communication with the ser(er
/rocesses through the program interface.
Kther processes call K?J1D- processes. In a dedicated ser(er
configuration0 a ser(er /rocess handles reUuests for a single user process. J multithread
ser(er configuration allows many user processes to share a small num2er of ser(er
processes0 minimi@ing the utili@ation of a(aila2le system resources.
991$3. IGJT I) J )-DB ?-B-?-4TIJD I4T-H?IT3>
Jns: Ta2le related to itself .Boreign key of the ta2le links to primary key of the same ta2le.
1$4. IGJT I) J \?JI)-\ )TJT-.-4T>
Jns: It is used to ?aise -&ceptions.
1$. IGJT I) ?KII"> GKI IT I) "IBB-?-4T B?K. ?KI4P.>
Jns: ?owid is the address of the row at where it is stored in the
data2ase. ?ownum is count of records whereas ?owid is identification of the each row.
OOO All The >e)t + 7%#DGA% OOO
'i features:
'i doins:
)upports J4)I<I)K standard )Ul 1''' synta&
57
MADHAV K
.ade easy for Jppln s<w tools to understand )Ul cueries
1. 4atural doin . Deft outer Voin
2. doin with Psing !. ?ight outer Voin
3. doin with K4 9$. Bull outer Voin
4. Inner doin %. 1ross Voin
1. * select empno0ename0sal0Vo20deptno0dname0loc
from emp natural Voin depta
2. * select empno0ename0sal0Vo20deptno0dname0loc
from emp Voin dept using6deptno7a
3. * select e.empno0 e.ename0 e.sal0 e.Vo20 e.deptno0d.dname0 d.loc from emp e doin dept d
on6e.deptno Y d.deptno7 a
4. * select e.empno0 e.ename0 e.sal0 e.Vo20 e.deptno0 d.dname0 d.loc from emp e Inner doin
dept d
on6e.deptno Y d.deptno7 a
. * select e.empno0 e.ename0 e.sal0 e.Vo20 e.deptno0 d.dname0 d.loc from emp e left outer
Voin dept d
on6e.deptno Y d.deptno7 a
!. * select e.empno0 e.ename0 e.sal0 e.Vo20 e.deptno0d.dname0 d.loc from emp e right outer
Voin dept d
on6e.deptno Y d.deptno7 a
9 $. * select e.empno0 e.ename0 e.sal0 e.Vo20 e.deptno0d.dname0 d.loc from emp e full outer
Voin dept d
58
MADHAV K
on6e.deptno Y d.deptno7 a
99 left outer Voin union right outer Voin Y full outer Voin
%. * select empno0ename0sal0Vo20deptno0dname0loc
from emp cross Voin depta
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4ew "ate Bunctions:
9 )ystimestamp : Hi(es date and time including fractional seconds in )-?E-? time @one
9 current[timestamp: Hi(es date and time including fractional seconds in 1DI-4T time @one
9 sysdate: Hi(es only date in ser(er time @one
9 current[date: Hi(es only date in client time @one
9 -&tract : Psed to retrie(e a particular (alue from the gi(en date 6 day <
month < year 7.
9 to[timestamp6d7 : 1on(erts gi(en date into date & time
information with am < pm .
9 d2time@one : Hi(es ser(er time @one (alue
9 Timestamp : "ata type
Jutomatically stores date and time information with am < pm .
*select systimestamp 0 current[timestamp from duala
*select sysdate0current[date from duala
*select d2time@one from duala
*select to[timestamp6sysdate7 from duala
2#+Van+#' !:4%:23 pm
*select e&tract6day from sysdate7 0
e&tract6month from sysdate70
e&tract6year from sysdate7 from duala
59
MADHAV K
create ta2le temp 6c1 timestamp7a
* insert into temp (alues6sysdate7a
* select 9 from tempa
2#+Van+#' !:2:23 pm
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4ew Heneral Bunctions:
9 1oalesce6e&pr10e&pr20e&pr30.......7 +++ /icks the first not null e&pression result .
9nullif 6 e&pr10e&pr2 7 +++ If e&pr1 and e&pr2 results are same it returns 4PDD (alue
otherwise it return e&pr1 result.
9 4(l26e&pr10e&pr20e&pr37 +++ If e&pr1 is null it manipulates e&pr3 0if e&pr1 is not null it
manipulates e&pr2.
*select coalesce61## , null0 12% + null , 1###0 12 9 null0
220 2340'%%'7 from duala ++ 22
*select ename0 Vo20 coalesce 6comm 9 20 sal 9 1.7 2onus
from empa
*select nullif61##0#9 270 nullif63##03# 9 1##70
nullif 6!##03## , 3##7 from duala ++ null 3## null
*select roll0 name0 nullif6fee02##7 from student
where course Y ^Kracle'i^a
*select ename0 Vo20 n(l26comm0sal , comm0sal7 net from empa
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.utiple Inserts:
60
MADHAV K
)upports to insert into more than 1 ta2le at a time.
Xut input must 2e retrie(ed from e&isting ta2le.
-&: .ake 3 empty ta2les same as "ept ta2le.
1reate ta2le "1 as select 9 from dept
where rownum is nulla
1reate ta2le "2 as select 9 from dept
where rownum is nulla
1reate ta2le "3 as select 9 from dept
where rownum is nulla
insert into "1 select 9 from depta
insert into "2 select 9 from depta
insert into "3 select 9 from depta
insert all
into "1 (alues6deptno0dname0loc7
into "2 (alues6deptno0dname0loc7
into "3 (alues6deptno0dname0loc7
select 9 from depta
1onditional Insert:
insert all
when 6deptno NY 4#7 then
into "1 (alues6deptno0dname0loc7
when 6deptno NY '#7 then
into "2 (alues6deptno0dname0loc7
61
MADHAV K
else
into "36dname0loc7 (alues6dname0loc7
select 9 from depta
insert all
when course Y ^Kracle'i^ then
into stu[oracle (alues6roll0name0fee7
when course Y ^d!i^ then
into stu[d!i (alues6roll0name0fee7
when course Y ^uni&^ then
into stu[uni& (alues6roll0name0fee7
select 9 from studenta
)tudent stu[oracle
+++++++++ ++++++++++++
?oll ?oll
name name
course fee
fee
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.erge :
Psed to compare the 2 ta2le contents and makes them eUual.
It supports only Ppdate and Insert operations .
*merge 1lauses:
into Temp T into ++ Target
using emp - Psing ++ )ource
62
MADHAV K
on 6 T.empno Y -.empno 7 Kn ++ doin condition
when matched then
update set t.sal Y e.sal0
t.comm Y e.comm0
t.deptno Y e.deptno0
t.Vo2 Y e.Vo20
t.mgr Y e.mgr
when not matched then
insert (alues6e.empno0e.ename0e.sal0e.comm0......7a
Xefore :
-mp + 1 1rore rows
Temp + 1opy of emp + 1 1rore rows
Jfter :
-mp +++ ### inserts & 1### Ppdates performed
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
?ename 1onstraint & 1olumn :
Jlter ta2le emp rename constraint sys[c##232 to pk[empa
Jlter ta2le emp rename column ename to emp[namea
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'i )upports :
Jd(anced Beatures of dJEJ
Impro(ed internal Jrchitecture related to dJEJ
)upports 5.D.

You might also like