: displays the all user in who w ho are currently working on ser(er
1#. $i!ger more information
: displays the all user who are currently working on ser(er with
11. Who a" #
: displays current user information
12. Which or where
: displays the location of the gi(en command
)y *ommands:
Du %& ile!a"e ' to find the si+e of one file
"u ,sk test.tt
Du %& ile!a"e( ile!a"e2 ). ' to find si+e of multiple files "u ,sk test.tt test2.tt
Du a
*Director+ !a"e, : -i(e the si+e of all files in that directory.
"u ,sk also can /e used to find si+e of all the files.
Du a *#! -ou!, ' #t Li%t %i/e o all ile%1oler %i/e i! re%e!t irector+ Du 34a&hr%tx5' "u for folder can /e used with any of these characters 0ut I am getting same result for "u ,tr
Du h *#! -ou!, ' co!%ier %i/e o irector+ while calcualati!g
ow to i! all the ile% i! all the irectorie% i! that oler7 uo%e 1ile% i! D% i% the oler which ha% %o "a!+ ile% a! al%o 2 1oler% #! -ou! a! Out -ou!. We wa!t the ile% re%e!t i! #! -ou! a! al%o Out 9ou!: #! that ca%e what !ee% to 9e u%e7 L% ;
=yn: $which pwd 13. <at data to the eiting files
: is use to create new files or to open eiting files or to append
: deleting files or directories ? rm filename5555555555555555deleting single file rm 5i filename55555555555555deleting files with confirmation rm file1 file25555555555555555deleting multiple files rmdir dirname55555555555555deleting the directory /ut the directory must /e empty rm 5r dirname5555555555555 deleting directory recursi(ely Ci.e. with tree strD rm ,ri dirname5555555555555 remo(e directory with confirmation rm
555555555555555555555 55555555555 5555555555 it delets all files
rm 5I 555555555555555 55555555555555555555 55555 delets all files with confirmation rm t 555555555555555555555it delets whose file name starts with EtF Gow to delete the directory which is not emptyH ?: m ,r Testing78ni. 1!. "&ir
: change directory =ys: $cd a/c $pwd5555556home6madha(6a/c using a/o(e cmd we can come out from a/c now we at 66home6madha( cd..555555555555555555555555555 to come out from current directory cd..6..555555555555555555555555 parent directory cd6555555555555555555555555555 it changes to root directory
5
cd J5555555555555555555555555it changes to home directory
: displayA list of all files & directories in a current directory
21.l%?"ore
: displayA list of all files & directories page /y page
22. l% a : displayA 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 current directory
: display list of all files & directories according to date of cr creation eation in a
2!. L% 1 directory
: display all list of files & directoriesA link filesA .ee files in a current
2. L%3x current directory
: display all list of files & directories according to width wise in a
2%. L%3L i.e. ' fields
: display all list of files & directories in a current directory in a long list
(@ 1ile t+e%
6
1D 55 Kor regular file iiD dLfor dir file IIID MLfor link file IN @ /Lfor /lock of filesND cL for char files here INA N is e>ice ile%5 2D Kile permissions 3D no. of links 4D owner name D group name !D file si+e in /ytes D "ate %D time 'D filename
3#. c"
: it compares two files char /y char
=ys: cmp file1 file2 ?:files in dsIn 0oundcmp type1.tt type2.tt type type1. 1.t ttt ty type pe2. 2.t ttt diff differ er
r: cha charr 2A 2A line line 2
?: a1: Gello -ood )orning
a2: Gello -ood ?(ening
If two lines are same then return nothing
If two files are are different then it displays line num/er with character position
31. co"".
: It display common lines /6w 2 files
=yn: *omm Kile1 file2
32. i 33. g 34. "ore
: it display different lines /6w 2 files : it display the file contents page /y page =yn: $@g filename : it also display the file contents page /y page
=yn: $more filename
34. hea
:it display the 1st n lines from the file =ys: $ head ,n filename
3. tail
: it display the last n lines from fr om file =yn: tail ,n filename
Tail Tail >n filename5555it indicates nth line to end of the line ?: tail >3# file Cin this file total no of records is 1##D it displays the records from 3# th to 1## 3!. wc
: it counts the no of linesA wordsA chars in a gi(en file.
7
=yn: $wc filename
iD wc ,l filename555555555555555555 it gi(es the no of lines in a gi(en file iiD wc ,w filename555555555555555it gi(es the no of words in a gi(en file IIID wc ,c filename555555555555555 it gi(es no. of char in file i(D wc 5lw filename55555555555555 it gi(es the no of lines and character in a gi(en file
3. OIM" *P" *GP*T?= or )?TP *GP*T?= iD
EF55555555it matches E#F or more chars
iiD iiD EHF EHF 55 5555 5555 5555it matches any single chars iiiD
555it matches any single chars in the gi(en list
i( i(DD E,E5 E,E5555 55555 55it matches any single char in the gi(en range 1D ls t55 t55555 555555 555555 555555 55555it list the files starts with EtF 2D ls s 555555 555555555 55555 5555 55it list the files that ends with E=F
3D ls /k /k55555 5555555 55555 555555 55555it list the files starts with E/F and ends with EkF 4D ls aH555 aH555555 555555 555555 55555 55it list the 2 characters filename 1 st later fallowed /y EaF and second letter is any one character
D ls/ ls/kn knt t555 555555 555555 55555 55it list the files starts with E/F or EkF or EnF or EtF !D ls a/c a/cdef defgh gh or ls lsa5h a5h55 55list the filesA first char /6w EaF to EhF
D ls /5 /5k kp5t p5td5n d5n55 555555 5555555 555 it list the files the 1 st character E/F to EkF 2 nd char EpF to EtF 3rd char EdF to EnF after that any a ny no of characters ls doesnFt care a/out *ase sensiti(e e: ls aeiou.tt and lsP?I<8.tt /oth will gi(e the same result 3%. gre
: glo/ally search a regular epression and print it
Is used for to search a string or regular epression in a gi(en fileCsD ID ?g: $ grep madha( sample <6p: 2nd line th line
8
th line
iiD ?g: $grep madha( a1A a2A a3:
a1:555555
a2:555555 a3:555555
iiiD $ grep techno 555555 it searches for techno in current dir files Call filesD i(D $grep techno soft sample55555 it searches for more than one word wor d Oe kept it in Q
$grep ,n techno sample55555555555555555555555 print along with the line num/ers $grep ,l techno 555555555555555555555555555555 list only file names $grep ,( Qtechno softR sample555555555555555 not matches print the lines $grep ,ci techno sample5555555555555555555555 Ignore case sensiti(e found no of lines $grep Qtechno R sample555555555555555555555 pattern
;egular exre%%io!' any string contains wildcard charctor knows as regular epression or pattern
These patterns are of t+e%:
<harctor atter!: the default pattern is char p pattern attern only iD $grep Qtechno R sample iiD $grep Q/ aeiou llR sample iiiD $grep Q/..dR sample555i.e. or matches any single charctor
Wor atter! :6S
6
6S 5555555start of the word 6555555 end of the word
?: grep QdR sample555555555555555it display the line starts withEdF
-rep QtheR sample55555555555555555 sample5555555555555 5555it list the lines start with EtheF
-rep Q6Sthe6R simple 5555555555 sample the line eactly start with EtheF
-rep Qt$R simple5555555555555555555 simple55555555555555 55555 list the line ends withEtF or last char isEt2#1'
-rep Q#5' $R sample555555555555 display the line ends with # to ' digit -rep Q /ktR sample555555555555 list the line starting with E/F or Ek EorFtF EorF tF -rep Q /ktR sample5555555555 list the line which is not start with E/F or EkF orEtF -rep QR89I$R sample 555555555display the line ha(ing only word E8niF -rep QU. $R5555555555555555555555 list the line which contains E4F characters C.D5555555555555555555555555555555555 represent single charctor -rep Q.R555555555555555555555555=ample it list all lines -rep Q6.R =ample: =ample: 55555555555555 55555555 555555 it lists the line start with C.D Oe use to search A $A as a charctor5555555 i.e.AVA$ -rep Q$R sample55555555555555 it list empty lines -rep ,c Q$R sample5555555555counts no of empty lines in a file -rep ,( Q$R sample5555555555 print not matches Ci.e. not emptyD lines -rep ,( Q$Rsample temp
10
)( temp sample5555555555555555555here /oth are delete empty files This command is used to show the Pfter 3 lines when the string is found -rep ,P 3 ,i Q*handraR emp.tt This command is used to show the 0efore 3 lines when the string is found -rep ,0 3 ,I QseR emp.tt If the no.of lines found are not eactly same as the lines found then it will result the lines that it found.
3'. gre epression
$grep Qhello
: it is used for search multiple strings /ut it doesnFt allow to search regular
techno 89IRsample5555555555it searches for hello or techno str 89I
4#. egre
: it is com/ination of grep and fgrep
$egrep Qhello hello 89IRsample 41. e
$egrep Q$R sample
: to replace a string
$ sed Qs6eisting string6new string6gR filename55sed is used to find and replace and grep is for find print Gere g is to state that replace eisting string with new string -lo/ally. If we want to replace only second instance then =ed Qs6 eisting string6new string62R Oe can use any delimiter to replace the command =ed QsV eisting stringV new string VgR Oe can replace the string in only one particular line =ed Q3 sV eisting stringV new string VgR
11
Oe can replace range of lines /y using /elow command =ed Q1A3 sV eisting stringV new string VgR
Oe can find any no.of lines 2 times /y using sed command =ed EpF emp.tt 5 This will print all lines 2 times Oe can print only particular lines of a file =ed ,n E1pW$pF emp.tt Oe can delete lines /y usin sed =ed E2 dF emp.tt
"elete
=ed E1dW $d E em emp.tt p.tt =ed E1A dF emp.tt
2 line
"elete
"elete
1 and last line
the line range from 1 to .
iD $sed Qs68ni6Minu6gi Qmadha(: 5555555555555 Ei Efor case sensiti(e iiD $sed Qs68ni6Minu6giR5555555555555555555555 whate(er lines starting with 89I are replaced /y Minu iiiD $sed Qs6$6I like 8ni6g IR sample55555555 empty string are filled with EI like 89IFF i(D $=ed Qs68ni66g IR sample55555555555555555 it search 89I if found replace with w ith EnothingF CemptyD 42. tr
: to translate a charctor iD tr QaR QpR Ss55555555555555555555 it read data from sample s ample and EaF is replaced /y EpF iiD tr QaeiouR QP?I<8RSsample5555replace char /y char iiiD tr QAR QltR Semp5555555555555555 whene(er QAR is there replace with ta/ space
: it is used for to retrie(e reYuired fields and characters from a gi(en file
12
?: madha( is good /oy551% chars *ut ,f 25 madha(555o6p: adha *ut ,c 151# madha( *ut ,c 51#A 152# madha(5555555 for e(ery line 51#A 152# characters *ut ,c 1A2A3 emp.tt
@rints
*ut ,c 153A45! emp.tt *ut ,c1#5 emp.tt
1A2 and 3rd char of each line
prints
@rint
1 to 3 and 4 to ! character of each line
the lines from 1# th to end position /y using cut
command Oe can print the lines /y using delimiter *ut ,dFAF ,f2 emp.tt
This
will print the 2nd word of each line /y taking EAF as
delimiter. *ut ,dFAF ,f2A3A emp.tt
This
will print the 2nd and 3rd words of each line /y
taking comma as delimiter. delimiter.
Gow to get the last field of a file. *at emp.ttV re(V cut ,dFAF ,f2 Vre(
44D Pa%te
: is used for to Zoin two or more files hori+ontally /y using delimiter
*at states filename
cat cities
paste ,d Q:Rstates citiestr
P@
Gydera/ad
P@: Gydera/ad
Tamilnadu
madras
Tamilnadu: madras
;arnataka
0angalore
;arnataka: 0angalore
;erala
Tri(andrum
)aharashtra
0om/ay
4D ort : it is used for to sort the file content. 0y default it sorts file contents /ased on P=*II (alues5default is ascending =ort sample iD sort ,r sample555555displays descending order
: it is used for to com/ine 2 or more cmds Vtake Vtake left side o6p to right
iD $who Vwc ,l555555555 count total no of lines CfilesD in current c urrent directory iiD $ lsVwc ,l555555555555displays total no of su/directories in the current directory iiiD ls ,l Vgrep QdR5555 displays total no of su/directories who stats with line noEdF iND $head 53# sampleVtail >2# sample555555 display the the lines from 2# to 3# from gi(en file (D $ grep 89I stud V cut ,f 2A 3Vsort filename 55555 display 89I students names & ph no in ascending order 4%@ $tee
: it is used to for to write data to the file as well as to the screen $grep 89I stud V cut ,f 2A 3 Vsort Vtee file1
F@ hell %criti!g' It is group of 89I commands and shell keywords The main concept of shell scripting is to handle tet files ID -ou!e %hell5555stea(e 0ourne 55555$55555555sh555 Csh as i!terreter@ ii@ -a%h %hell C/orne again shellD 555same as a/o(e55ad(anced (ersion of 0ourne is 0P=G CMinu default shellD iii@ Hor! %hell555555"a(id korn5555$5555555555ksh CinterpreterD 5555 used as PI default shell )ostly used shell is korn shell it supports re usa/ilityA all shell designed on /ourn shell #@ $&%h
: shift to korn shell
I(D $echo $0
I2@ $alia%
: it displays current child shell name : it lists all alias names
15
I@ C!alia% alia% !a"e%' to delete alias names IF@ $ hi%tor+
: it displays the pre(iously eecuted eecuted commands
II@ Echo
: it display the string on screen scree n CmonitorD
%@ chgre : to change group name of the file \ chgrp group name filename %@ $write ser(er
: it is user for to with the users /ut the user should /e logged into the
$write techno2 Gello
iiD $mesg n55deny the msg iiiD mesg y5to allow msges
*mtl>d 'D aw&!aw& fi file
: scan for patterns in a file and process the results
!#@ cat
: concatenate ClistD or file
!1D ch%h Cpaawd ,e65sD userlogin7shell: change the user login shell !2D
: report the summary of disk /locks and nodes free and in use
iD df ,k555it displays the disk space in /ytes
iiD df ,h555it displays disk space in kilo /ytes
iiiD df ,g555it displays the disk space in giga /ytes
!3Du :it displays the directory wise d disk isk usage in form of /locks each /lock si+e is 12 /ytes !4Dg /i
:to create a +ip file
? $g+ip filename5555o6p: filename.g+ To *reate multiple Xip files to a single Xip file we use /elow command Xip my+ip.+ip emp.tt The a/o(e command will +ip all the files to )y+ip.+ip and we can c an get all files starting with emp. !D gu!/i
: to un+ip the files
?: gun+ip filename.g+ !!. co"re%%
: it also used for to +ip the file555 it used to sa(e with .+ format
!D C!co"re%%
: same as a/o(e
-+ip sa(es more memory than compress !%D /cat
: it used to displays +ip file contents in reada/le format
17
$+cat sample.g+
<r $+cat sample.+ !'D To &ill oregrou! o9 c!tlJc or c!tlJ/ $ sleep ## *ntl>c $ sleep 1##& #D % or $ % : it displays current user account running process list Cshow status of acti(e processD 1D $% a: it displays all user accounts running process list 2D Hill
: it kill /ackground process
?: kill @I" 3D tel!et
: to connect to remote ser(er
4D t: file transfer protocol 55555transfer files from one ser(er to another
$ ftp ipaddress
Mogin: 5555555 @assword: 555555 Ktpls Cser(erD KtpVlsCclientD Ktpget filename Cto download a fileD Ktpmget file1 file255555 Cto download multi filesD Ktpput filename Cto upload a fileD Ktpmput file1 file255555 Cto upload multi filesD D1t: to transfer files from one ser(er user account to another ser(er user account $su root 55to switch to admin !D Wall : it is used for to sent /roadcast message to all users who are currently working on ser(er
18
$wall Gappy new5year *ntl>d D"ail mail
:it is used for to send the mailA if user is not logged in then also we can send
iD $ mail techno1 *ntl>d e(ery user contains mail/o at a time we can send msg to multiple users 2D $mail techno1 techno2 techno 3 =u/: from techno *ntl>d iiiD $ mail technoSstud stud send content as a mail to techno3 mail is the cmd to read mails in the mail/o $mail 1first mail 2second mail reading &2 it Yuickly opens second mail &Y55Yuit from mail /o &w to sa(e mail contents to a file &pprint mail contents &r55replays &d5delete mails %@$"ail :to :to read mails send to secondary mail/o 'D e"ac%
:full screen editor
%#@ echo
: echo the tet string to on monitor
%1D ile
: classify the file type
19
%2D exr
: e(aluates the argumentsA used to do arithmeticAetc in the shell
%3D i!
: find filesA matching a type or pattern
%4D o%t!a"e
: display or set the name of the current machine
%Dl!
: link the source to target
%!Dl Al%tat
:show the status of the print Zo/s
%Dlr:l
:print to defind printer
%%D lr": ca!cel
: remo(e a print Zo/ from the print Yuee
%'D "a!
:display manual of gi(en cmd
0@o
:octal dump a /inary fileAin octalAP=*IIAheAdecimal or char
'1Da%%w
:to set or change password
'2D r
: filter the file and print it on the terminal
'3D rc ho%t!a"e
: remotely copy files from this machine to another machine
'4D rlogi!e ho%t!a"e: login remotely to another machine 'D r%h ho%t!a"e
: remote shell to run on another machine
'!D %crit ile eecuted
: sa(es e(erything that appears on the screen to file until eit is
'D %ource ile
: read cmds from the file and a nd eecute them in the current shell
'%D %tri!g ile
: used to search /inary files for P=*II strings
''D t+
: set or display terminal control options
1##D uuecoe ile
: decode a uuencoded fileA recreating the original file
1#1D uue!coe !ew !a"e : encode the /inary file to 5/it P=*IIAusefull when sending (ia emailA to /e "ecode as new name at destination 1#2D >i
: (isual Afull screen editor
1#3D o9%
: display /ackground and suspended processes
1#4@ &ill (
: remo(e suspended process \1
1#D to
: display the currentA most computer5intensi(e commands
1#!D o%>iew
: display the operating system statistics
1#D %ete!>
: list en(ironmental (aria/les
20
CN#
What i% "ea!t 9+ a%%w ile7 This file maintains each and e(ery user information with fields. The fields are 8sername: passwd: uid: gid: fullname: home: shell.
What i% hell7 =hell is a command line interpreter. =hell acts as an interface /etween user and the kernel.
What i% Her!el7 ;ernel is core part part of 89I o6s. It is a group of hundreds of system calls.
What are iere!t la>or% o C!ix o%7 Pny operating system designed /ased on uni kernel called as fla(our of uni. The following are some fla(ours of uni Minu 5555 ed Gat =un solaris 555 =un )icrosystem I0)5PI 55555 I0) Gp5u 55555 G@ =co5uni 55555 santa crus operations II555555 =ilicon -raphics.
ow to co+ "ultile ile% a! irectorie% i!to %o"e other irector+7 cp 5r source7directory destination7directory ow to %ee hoe! ile%7 Ms ,a
ow to %ee ile% a! %u9irectorie% ile% recur%i>el+7 Ms ,
ow to %ee ile% i! lo!g li%t or"at age wi%e7 Ms ,l V more
ow to ie!ti+ whether a ile i% !or"al ile or irector+7
22
$ls 5l filename6directoryname if the first digit is 5 then it is fileA if it is d then it is directory file
What i% the iere!ce 9etwee! l% 3r a! l% 3;7
ls 5r lists the files in re(erse alpha/etical order. order... .. whereas ls 5 lists the files and directories recursi(ely
The iere!ce 9etwee! a %ot li!& a! a har li!&7 P sym/olic CsoftD linked file and the targeted file can /e located on the same or different file system while for a hard link they must /e located on the same file system.
what are the iere!t co""a!% u%e to create ile%7 1.touch 5 to create empty files Ce.gD 5 touch Sfilename 2.(i Sfilename 3. catfilename
Li%t %o"e wil car character%7 H 5 Iit matches any single character 5 It matches +ero or more characters 5 It matches any single character in gi(en list
. 3 It matches any single character ecept enter key character what i% the outut o the ollwi!g co""a! ' l% 4a3"!o3r5Q
list all the files in the current directory starting alpha/et is /etween a to m or n or /etween o to r
which co""a! i% u%e to ie!ti+ the t+e o the ile7 file
23
gre "ea!% -lo/ally search a regular epression and print it
ow o +ou %earch or a %tri!g i!%ie a gi>e! ile7 grep string filename
ow o +ou %earch or a %tri!g i!%ie a curre!t irector+7 grep string
ow o +ou %earch or a %tri!g i! a irector+ with the %u9irectorie% recur%e7 grep 5r string
Diere!ce 9etwee! gre: egre a! gre
grep : does not accept more then one epression
egrep : accepts more than one pattern for search. Plso accepts patterns from a file.
fgrep : accepts multiple patterns /oth from command line and file /ut does not accept regular epressions only strings. It is faster than the other two and should /e used when using fied strings.
What are li!e atter!%7 5 start of the line $ 5 ?nd of the line
ow to %earch e"t+ li!e% i! a gi>e! ile7 -rep Q$R Sfilename
ow to cou!t !o o 9la!& li!e% i! a ile7 -rep ,c Q$R Sfilename
What i% atter! to %earch F igit wor i! a ile7 -rep QS#5' #5' #5' #5'R filename
What i% atter! to %earch the li!e ha>i!g o!l+ three character%7 -rep Q)$R filename
What i% atter! to i%la+ li!e% e!i!g with S$R character i! a gi>e! ile7 -rep Q$$R filename
ow to i%la+ 2 a! F th ile% ro" a gi>e! ile i the eli"etr i% S'R7 *ut ,dR:R ,f 2A4 filename
ow to i%la+ u!iue li!e% ro" a gi>e! ile7 =ort ,u filename
ow to eli"i!ate co"letel+ ulicate li!e% ro" a gi>e! ile7 8niY ,u filename ow to re"o>e all ulicate li!e% ro" a ile7 8niY ,u filename tempfilename )( tempfilename filename
ow to elete ShelloR wor ro" a gi>e! ile7 =ed Qs6hello66R filename awk <o""a! <o""a!
is awk is
a powful 8ni command. It allows the user to manipulate files that are s structured tructured as columns of data and
<nce you understand the /asics of awk you you will find that it is surprisingly useful. Bou can use it to automate things in ways you ha(e ne(er thought a/out. It can /e used for data processing and for automating the application of 8ni commands. It also has many spreadsheet5type functionalities. There are two ways to run awk . P simple awk command command can /e run from the command line. )ore comple tasks should /e written as awk programs programs C]scripts]D to a file. ?amples of each are pro(ided /elow.
Exa"le' ^
awk _pattern _pattern
`action_ input5file output5file
meaning: take each of the input the line contains the pattern apply the action to the line and write theline resulting line tofileW theifoutput5file.
25
If the pattern is omittedA the action is applied to all lines:
ow to co"are two ile% are %a"e or !ot7 *mp
ow to i%la+ the ir%t (0 li!e% ro" a ile7 Gead 51# filename
Write a o!e li!e co""a! to co!>ert all the caital letter% o a ile te%t i!to lower ca%e7 cat filename V tr ]P5X] ]a5+]
The ieli!e to li%t the i>e large%t ile% i! the curre!t irector+ i%
ls 5l V tr 5s _ _ V sort 5t _ _ 5fnr >4 5 V head ,
The ieli!e to i! out the !u"9er o ti"e% the character 7 occur% i! the ile i% tr 5dc _H_ S file V wc 5c
C "elete all the characters ecept ecept H and then make a word count.D
ow to cou!t total !o. o u%er% wor&i!g i! the %+%te"7 Oho V wc ,l
ow to i%la+ the li!e% ro" I to (0 ro" a gi>e! ile7 Gead 51# filename V tail >
what will 9e outut o ollowi!g co""a!7 echo STec!o%otR ? wc c '
What i% the eault u"a%&7 #22
26
What i% the eault er"i%%io! or 1ile Director+ 7 The "efault pri(ileges for file : !44 The default pri(ileges for directory :
What CN# co""a! will co!trol the eault ile er"i%%io!% whe! ile% are create7 8mask
Exlai! the rea: write: a! execute er"i%%io!% o! a CN# irector+. ead allows you to see and list the directory contents. Orite allows you to createA edit and delete files and su/directories in the directory. ?ecute gi(es you the pre(ious read6write permissions plus allows you to change into the directory and eecute programs or shells from the directory.
What i% ch"o: chow! a! chgr7 *hmod : It is used for to change permissions on files *hown : It is used for to change ownership of a file *hgrp : It is used for to change group of the file
# the ow!er oe%!,t ha>e write er"i%%io! o! a ile: 9ut hi%her grou ha%: ca! he%he eit it7 9o. Ge6she can_tA/ecause the owner_s permission o(errides the group_s. To %ee li%t o ile% a! irectorie% :what er"i%%io! reuire7 ead permission
What are P#D%7 They are process I"s gi(en to processes. processes . P @I" can (ary from # to !3.
ow o +ou li%t curre!tl+ ru!!i!g roce%%7 ps
ow o +ou %to a 9ac&grou! roce%%7 kill pid ow o +ou i! out a9out all ru!!i!g roce%%e%7
% 3ag ow o +ou %to all the roce%%e%: excet the %hell wi!ow7 kill # ow o +ou ire a roce%% i! the 9ac&grou!7
27
.roce%%3!a"e
What oe% the co""a! &ill 3 $U o7 kills the last /ackground process
i there i% a roce%% u wa!t to ru! e>e! ater exiti!g the %hell what i% the co""a! u%e7 9ohup
which co""a! will get execute e>e! ater +ou log out7 9ohup
which %ig!al ca!!ot 9e trae7 kill ,'
ow to reirect %ta!ar error to a ile7 A!%wer 2 filename What oe% the to co""a! i%la+7 top command displays the current ammount of memory occupied /y the currently eecuting 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!7 Oall
What i% the co""a! to %e! "ail to other u%er7 )ail username
ow to oe! %eco!ar+ "ail 9ox7 )ail 5f
What o +ou o i +ou o!Vt wa!t to 9e i!terrute 9+ other u%er%V "e%%age%7
28
Pns. mesg n
hell criti!g #!ter>iew ue%tio!%
Diere!ce 9etwee! the outut o echo QQ a! echo Q Q echo lists all a ll the filenames in the current directory.. echo lists all the filenames in the current directory twice.
The other wa+ o ru!!i!g %hell %crit aart ro" u%i!g %h co""a! a! ch"o7 ans:5 using b we can run a shell script
1'. Gow do you refer to the arguments passed to a shell scriptH 5 $(: $2 a! %o o!. $0 i% +our %crit !a"e. 2#. OhatFs the conditional statement in shell scriptingH 5 i co!itio!X the! ) i 21. Gow do you do num/er comparison in shell scriptsH 5 5 e: 3!e: 3lt: 3le: 3gt: 3ge 22. Gow do you test for file properties in shell s hell scriptsH 5 5 % ile!a"e tell% +ou i the ile i% !ot e"t+: 3 ile!a"e tell% +ou whether the argu"e!t i% a ile: a! !ot a irector+: 3 ile!a"e te%t% i the argu"e!t i% a irector+: a! !ot a ile: 3w ile!a"e te%t% or writea9ilit+: 3r ile!a"e te%t% or reaa9ilit+: 3x ile!a"e te%t% or executa9ilit+ 23. Gow do you do 0oolean logic operators in shell scriptingH 5 U te%t% or logical !ot: 3a te%t% or logical a!: a! 3o te%t% or logical or. 24. Gow do you find out the num/er of arguments passed to the shell s hell scriptH 5 $Y 2. OhatFs a way to do multile(el if5elseFs in shell scriptingH 5 i co!itio!X the!
%tate"e!tX eli co!itio!X %tate"e!tX i 2!. Gow do you write a for loop in shellH 5 or >aria9le !a"eX i! li%tX o %tate"e!tX o!e 2. Gow do you write a while loop in shellH 5 while co!itio!X o %tate"e!tX o!e 2%. Gow does a case statement look in shell scriptsH 5 ca%e >aria9leX i! o%%i9le3 >alue3(X@ %tate"e!tXZZ o%%i9le3>alue32X@ %tate"e!tXZZ e%ac 2'. Gow do you read key/oard input in shell scriptsH 5 rea >aria9le3!a"eX 3#. Gow do you define a function in a shell scriptH 5 u!ctio!3!a"e@ Y%o"e coe here retur! X 31. Gow does getopts command workH 5 The parameters to your script can /e passed as 5n 1 5 2#. Inside the scriptA you can iterate through the getopts array as while w hile getopts n: optionA and the (aria/le $option contains the (alue of the entered option.
0atch file:
29
0atch files allow )=5"<= and )icrosoft Oindows users to create a lists of commands to run in seYuence once the /atch file has /een eecuted. eecuted. Kor eampleA a /atch file could /e used to run freYuently run commandsA deleting a series of filesA mo(ing filesA etc. P simple /atch file does not reYuire any special programming skills and can ca n /e done /y users who ha(e a /asic understanding of )=5"<= commands. commands.
O;A< O; A<LE LE i 1A[,% 1A[,%
1.
OGPT I= "PTP < I9K<)PTI<9H
Pns: The )atter that we feed into the *omputer is called "ata or Information.
2.
OGPT I= "PTP0P=?H
Pns: The *ollection of Interrelated "ata is called "ata 0ase.
Pns: Kor a system to ualify as ?MPTI<9PM ?MPTI<9PM "PTP0P=? "PTP0P=? )P9P-?)?9T systemA it must use its ?MPTI<9PM facilities to )P9P-? the "PTP "PTP0P=?. 0P=?.
.
OGPT I= <"0)=H
Pns: </Zect CorientedD elational "ata 0ase )anagement =ystem is one that can store dataA the relationship of the dataA and the /eha(ior of the data Ci.e.A the way it interacts with other dataD.
!.
9P)? =<)? *<""_= 8M?=.
30
Pns: "r. ?.K ?.K.. *odd presented 12 rules that a data/ase must o/ey if it is to /e considered truly relation relational. al. <ut thoseA some are as follows follows aD The The ru rule les s st stem em ffro rom m a sin singl gle e rule rule55 the the E+er E+ero o rule ruleF: F: Kor Kor a syst system em tto o ua uali lify fy as as ?MPTI<9PM "PTP0P=? "PTP0P=? )P9P-?)?9T systemA it must use its ?MPTI<9PM facilities to )P9P-? the "PTP0P=?. /D
Info Inform rmat atio ion n ule ule:: Ta Ta/ula /ularr ep epres resen enta tati tion on of Info Inform rmat atio ion. n.
cD
-u -uar aran ante teed ed Pcc Pccess ess ul ule: e: 8ni 8niYu Yuen enes ess s of tup tuple les s for for gu guara arant nteed eed ac acces cessi si/i /ili lity ty..
dD )is )issin sing g Info Informa rmatio tion n ule ule:: = =yst ystema ematic tic represe representa ntatio tion n o off miss missing ing inform informati ation on as 98M 98MM M Nalues. eD
*om *ompr preh ehen ensi si(e (e "ata "ata =u/ =u/5Ma 5Mang ngua uage ge ul ule: e: M M to supp support ort "a "ata ta def defin init itio ionA nA
Niew definitionA "ata manipulationA IntegrityA Puthori+ation and =ecurity.
Pns: aD ierarchical Moel' The Gierarchical )odel was introduced in the Information )anagement =ystem CI)=D de(eloped /y I0) in 1'!%. In this data is organi+ed as a tree structure. ?ach tree tr ee is made of nodes and /ranches. The nodes of the tree represent the record types and it is a collection of data attri/utes entity at that point. The topmost node in the structure is called the root. 9odes succeeding lower le(els are called children.
/D Networ& Moel' The 9etwork )odelA also called as the *<"=BM data/ase structureA is an impro(ement o(er the Gierarchical modeA in this model concept of parent and child is epanded to ha(e multiple parent5child relationshipsA i.e. any child can /e su/ordinate to many different parents Cor nodesD. "ata is represented /y collection of recordsA and relationships among data are represented /y links. P link is an association /etween precisely two records. )any5to5many relationships can eists /etween the parent and child.
cD ;elatio!al Moel' The elational "ata/ase )odel eliminates the need
31
for eplicit parent5child relationships. In "0)=A data is organi+ed or gani+ed in two5dimensional ta/les consisting of relationalA i.e. no pointers are maintained /etween ta/les.
%.
OGPT I= "PTP )<"?MI9-H
Pns: "ata )odeling descri/es relationship /etween the data o/Zects. The relationships /etween the collections of data in a system may /e graphically represented using data modeling.
Pns: ?ntity: Pn ?ntity is a thingA which can /e easily identified. Pn entity is any o/ZectA placeA personA concept or acti(ity a/out which an enterprise records data. Pttri/ute: Pn attri/ute is the property of a gi(en entity entity.. elationship: elationship is an association among entities.
1#.
OGPT I= ? ?5)<"?MI9-H
Pns: The ?5 modeling techniYue is the Top "own Ppproach. ?ntity relationship is techniYue for analysis and logical modeling of a systemFs data reYuirements. It is the most widely used and has gained acceptance as the ideal data/ase design. It uses three /asic units: entitiesA their attri/utes and the relationship that eists /etween the entities. It uses a graphical notation for representing these.
11.
OGPT I= 9<)PMIXPT XPTI<9H <9H
Pns: 9ormali+ation is a step5/y5step decomposition of comple records into simple records.
Pns: 15Tier "ata/ase Prchitecture is /ased on single systemA which acts as /oth ser(er and client. 25Tier Prchitecture is /ased on one ser(er and client. 35Tier Prchitecture is /ased on one ser(er and client out that on client act as a remote system. 95Tier Prchitecture is /ased on 9 no. <f ser(ers and 9 no. <f clients.
1. 1.
OGP OGPT P? P? P TP TP0M?A 0M?A *<M8 *<M8)9 )9AA P9" P9" ?*< ?*<" "H H
Pns: Ta/le: Ta/le: P Ta/le Ta/le is a data/ase o/Zect that holds your data. It is made up of many columns. ?ach of these columns has a data type associated with it. *olumn: P columnA referred to as an attri/uteA is similar to a field in the file system. ecord: P rowA usually referred to as tupleA is similar to record in the file system.
9<95@<*?"8PM MP9-8P-?H Pns: @rocedural @rocedu ral Mangu Manguage age 9<95@rocedur 9<95@rocedural al Manguage Manguage
33
P program in this implements a step5/y5step algorithm to sol(e the pro/lem. It contains what to do /ut not how to do .
1.OGPT TB@? <K MP9-8P-? ]=M] I=H Pns: =M is a 9on5proceduralA 4th generation ManguageA6 which concerts what to do rather than how to do any process.
Pns: Truncate Truncate *ommand will delete all the rec records ords where as "elete *ommand will delete specified or all the records re cords depending only on the condition gi(en.
Pns: 1D 9ames must /e from 1 to 3# /ytes long. 2D 9ames cannot contain Yuotation marks. 3D 9ames are not case sensiti(e. 4D P name must /egin with an alpha/etic character from your data/ase character set and the characters $ and \. 0ut these characters are discouraged. D P name cannot /e <P*M? reser(ed res er(ed word. !D P name must /e uniYue across its namespace. </Zects in the name space must ha(e different names. D P name can /e enclosed in dou/le Yuotes.
2!.. 2!
G<O G<O )P9 )P9B B *<M *<M8 8)9 )9= = *P9 *P9 P TP TP0M? GPN GPN?H
Pns: *har Csi+eDA 9char Csi+eDA Narchar2 Csi+eDA 9(archar2 Csi+eD data types for character (aluesA 9um/er CprecisionA scaleDA 9um/erA 9um/er CnDA KloatA Kloat C/inary precisionD data types for numerical (aluesA "ate data type for date (aluesA MongA aw Csi+eDA Mong awA *lo/A 0lo/A 9clo/A 0file for large o/Zects.
1D The maimum si+e is 4-0. 2D M<0s Cecept 9*M<0D can /e attri/utes of an o/Zect type. 3D M<0s support random access to data. 4D )ultiple M<0 columns per ta/le or M<0 attri/utes in an o/Zect type. 1D The maimum si+e is 2-0. 2D M<9-s cannot.
3D M<9-s support only
seYuential access. 4D <nly one M<9- column was allowed in a ta/le
Pns: Narchar2 is similar to *har /ut can store (aria/le no. <f characters and while Yuerying the the ta/le (archar2 trims the etra spaces from the column and fetches the rows that eactly match the criteria.
Pns: *onstraint: *onstraints are representators of the column to enforce data entity and consistency.There consistency.There r two tw o le(els 1D*olumn5le(el constraints 2DTa/le5le(el 2DTa/le5le(el constraints. 3. 3.
Pns: 8niYue and 9ot 9ull is a com/ination of two *onstraints that can /e present any num/er of times in a ta/le and canFt /e a referential key to any column of an another ta/le where as @rimary ;ey is single *onstraint that can /e only once for ta/le and can /e a referential key to a column of another ta/le /ecoming a referential integrity.
3.. 3
OGP OGPT I= I= P *<)@< <)@<=I =IT? T? @I) @I)P PB B ;?B ;?BH H
Pns: P @rimary key created on com/ination of columns is called *omposite @rimary ;ey.
43. OGPT P? MI)ITPTI<9= MI)ITPTI<9= <K *G?*; *G ?*; *<9=TPI9TH Pns: In this we can_t specify @seudo *olumns like sysdate etc.
44. OGPT I= "IKK??9*? 0?TO??9 ?K??9*?= P9" K<?I-9 ;?B *<9=TPI9TH Pns: eferences is used as column le(el key word where as foreign key is used as ta/le le(el constraint.
4. OGPT I= ]<9 "?M?T? *P=*P"?]H Pns: when this key word is included in the definition of a child ta/le then whene(er whene(er the the records records from from the the parent parent ta/le ta/le is deleted deleted automaticall automatically y the respecti(e respecti(e (alues in the child ta/le will /e deleted.
4!. OGPT I= @P?9T5*GIM" @P?9T5*GIM" < )P=T?5"?TPIM )P=T?5"?TPIM ?MPTI<9=GI@H Pns: P ta/le which references a column colum n of another ta/leCusing eferencesDis called asTa/le a child ta/leCdetail ta/leD and a ta/le which is /eing referred is called @arent @arent C)asterD Ta/le .
#. OGPT I= P @=?8"<5*<M8)9H 9P)? =<)? @=?8"<5*<M8)9= <K <P*M?H Pns: *olumns that are not created eplicitly e plicitly /y the user and can /e used eplicitly eplicitly in Yueries are called @seudo5*olumns. ?:curr(alAnet(alAsysdateAnewAoldAsYlcodeAsYlerrmArownumArowidAle(el
1. OGPT K< ]<"? 0B] *MP8=? K< P 8?BH Pns: To arrange the Yuery result in a specified <rder CascendingAdescendingD /y default it takes ascending order.
2. OGPT I= ]-<8@ 0B] 8?I?=H Pns: To group the Yuery results /ased on condition.
4. OGPT I= "IKK??9*? 0?TO??9 *<89T CDA *<89T CD K89*TI<9=H Pns: *ount CD will count the specified s pecified column whereas count CD will
40
count total no. of rows in a ta/le.
. OGPT K< <MM8@ P9" *80? <@?PT<= P?H Pns: To get su/totals and grand total of (alues of a column.
!. OGPT I= P =8058?BH Pns: P Yuery within a Yuery Yuery is called a su/ Yuery where the result of inner Yuery will /e used /y the outer Yuery. Yuery.
. OGPT P? =M <@?PT<=H <@?PT<=H Pns: Nalue CDA ef CD is =M operator. C 8sed with </Zects D
%. ?@MPI9 ]P9B]A]=<)?]A]PMM]A]?I=T=] <@?PT<=H Pns: A!+: The Pny Cor itFs synonym =<)?D operator computes the lowest (alue from the set and compares a (alue to each returned /y a su/ Yuery.
All' PMM compares a (alue to e(ery (alue returned /y =M. Exi%t%' This operator produces a 0<<MOP9 results. If a su/ Yuery produces any result then it e(aluates it to T8? else it e(aluates it to KPM=?.
'. OGPT I= P *<?MPT?" =80 8?BA G<O IT I= "IKK??9T K<) P 9<)PM =80 8?BH Pns: P correlated su/Yuery is a nested su/YueryA which is eecuted once for each E*andidate rowF /y the main YueryA which on eecution uses a (alue from a column in the outer Yuery. In normal su/ Yuery the result of inner Yuery is dynamically su/stituted in the condition of the outer Yuery where as in a correlated su/YueryA the column
41
(alue used in inner Yuery refers to the column (alue present in the outer Yuery forming a correlated su/Yuery.
!#. OGPT I= P <I9 5 TB@?= <K <I9=H Pns: P Zoin is used to com/ine two or more ta/les logically to get Yuery results.
There are four types of oins namely ?8I oin
9<95?8I oin
=?MK oin <8T? oin.
!1. OGPT P? )I9I)8) ?8I?)?9T= K< P9 ?8I5<I9H ?8I5<I9H Pns: There shold /e atleast one common column /etween the Zoining ta/les.
!2. OGPT I= "IKK??9*? 0?TO??9 M?KTA M?KTA I-GT <8T? <I9H Pns:If there r any (alues in one ta/le that do not ha(e corresponding (alues in the otherAin otherAin an eYui Zoin that row will not /e selected.=uch rows can /e forcefully selected /y using outer Zoin sym/olC>D on either of the sidesCleft or rightD /ased on the reYuirement.
!3. OGPT I= "IKK??9*? 0?TO??9 ?8I P9" =?MK <I9=H Pns: =?MK <I9 is made within the ta/le whereas ?8I <I9 is made /etween different ta/les ha(ing ha(ing common column.
Mast day CdDA 9et7day CdA dayD.add7monthsCdAnDA ?tract
<o!>er%io! 1u!ctio!%'
To To7charA 7charA To To7dateA 7dateA To7num/er To7num/er
!. OGPT I= "IKK??9*? 0?TO??9 )P CD P9" -?PT?=T CD K89*TI<9=H Pns: )P is an aggregate function which takes only one column name of a ta/le as parameter whereas -reatest is a general function which can take any num/er of (alues and column names from dual and ta/le respecti(ely.
43
!%. OGPT K< 9NM CD K89*TI<9 I=H Pns: 9NM Kunction helps in su/stituting a (alue in place of a 98MM.
!'. OGPT K< "?*<"? CD K89*TI<9 I=H Pns: It is su/stitutes (alue /asis and it actually does an _if5then5else_ test.
#. OGPT I= "IKK??9*? 0?TO??9 TP9=MPT? TP9=MPT? CD P9" ?@MP*? CD K89*TI<9=H Pns: TranslateCD TranslateCD
is a superset of functionality pro(ided /y eplaceCD.
1. OGPT I= "IKK??9*? 0?TO??9 0?TO??9 =80=T CD P9" I9=T CD K89*TI<9=H Pns: =u/strCD will return the specified part of a string whereas
InstrCD return the position of the specified part of the string.
2. OGPT I= P 8MIP9 "PB "PB 98)0?H Pns: It will return count of the no. <f days /etween anuary 1A 412 0* and the gi(en date.
3. G<O T< "I=@MPB TI)? K<) P "PT? "PTPH "PTPH Pns: 0y using time format as _hh hh24: mi: ss_ in to7charCD function.
4. G<O T< I9=?T I9=?T "PT "PT? ? P9" TI)? I9T< P "PT? *<M8)9H Pns: 0y using format _dd5mon5yy hh hh24: mi: ss_ in to7dateCD function.
. OGPT I= "IKK??9*? 0?TO??9 T<7"PT? T<7"PT? CD P9" T<7*GP CD *<9N?=I<9 K89*TI<9=H
44
Pns: To7date To7date con(erts character date to date format whereas w hereas To7char To7char function con(erts date or numerical (alues to characters.
!. OGPT I= P NI?OH G<O IT I= "IKK??9T "IKK??9T K<) P TP0M? TP0M?H H Pns: Niew is data/ase o/ZectA which eists logically /ut contains no physical data and manipulates the /ase ta/le. Niew is sa(ed as a select statement in the data/ase and contains no physical data whereas Ta/le eists physically.
. OGPT I= "IKK??9*? 0?TO??9 0?TO??9 =I)@M? P9" *<)@M? NI?O=H Pns: =imple (iews can /e modified whereas *omple (iews Ccreated /ased on more than one ta/leD cannot /e modified.
%. OGPT I= P9 I9MI9? NI?OH Pns: Inline (iew is /asically a su/Yuery with an alias that u can use like a (iew inside a =M statement. It is not a schema o/Zect like =M5o/Zect.
'. G<O T< 8@"PT? P *<)@M? NI?OH Pns: 8sing _I9=T?P" <K_ TI--?= *omple *omple (iews can /e 8pdated.
%#. OGPT K< ]OITG *G?*; <@TI<9] K< P NI?OH Pns: ]OITG *G?*; <@TI<9] clause specifies that inserts and updates r performed through the (iew r not allowed allowed to create rows which the (iew cannot select and therefore allows integrity constraints and data (alidation checks to /e enforced on data /eing inserted or updated.
%1. OGPT I= P9 I9"?H P"NP9TP-? P"NP9TP-? <K P9 I9"? Pns: Pn Inde is a data/ase o/Zect used n <racle to pro(ide Yuick
45
access to rows in a ta/le. Pn Inde increases the performance of the data/ase.
%2. OGPT I= P =?8?9*?H @=?8"<5*<M8)9= P==<*IPT?" OITG =?8?9*?H Pns: =eYuence is a "ata/ase </Zect used to generate uniYu uniYue e integers to use as primary keys. 9et(alA *urr(al are the @seudo *olumns associated with the seYuence.
%3. OGPT I= P *M8=T?H OG?9 T< 8=? P *M8=T?H G<O T< "<@ P *M8=T? OG?9 *M8=T??" TP0M? ?I=T=H Pns: *luster and a nd Indees are transparent to the user. *lustering is a method of storing ta/les that are intimately related and are often Zoined together into the same area on the disk. Ohen cluster ta/le eists then to drop cluster we ha(e to drop the ta/le first then only cluster is to /e dropped.
%4. OGPT I= P =9P@=G<T < )PT?IPMIX?" NI?OH Pns: )ateriali+ed (iews can /e used to replicate data. ?arlier the data was replicated through *?PT? * ?PT? =9P@=G<T command. 9ow *?PT? )PT?IPMIX?" NI?O can /e used as synonym for *?PT? =9P@=G<T. =9P@=G<T. uery performance is impro(ed using the materiali+ed (iew as these (iews pre calculate c alculate epensi(e Zoins and aggregate operations on the ta/le.
%. OGPT I= P =B9<9B)H Pns: P =ynony =ynonym m is a data/ase o/Zect that allows you you to create alternate names fo forr <racle ta/les and (iews. It is an alias for a ta/leA (iewA snapshotA seYuenceA procedureA function or package.
%!. OGPT I= "IKK??9*? 0?TO??9 @INPT? @INPT? P9" @80MI* =B9<9B)H Pns: <nly the user or ta/le owner can reference @ri(ate synonym whereas any user can reference the @u/lic synonym.
46
%. OGPT I= "IKK??9*? 0?TO??9 0?TO??9 ]=M] P9" ]=M@M8=] *<))P9"=H Pns: =M commands are stored in the /uffer whereas =M@M8= are not.
'2. OGPT K< -P9T *<))P9" OITG ]OITG -P9T <@TI<9]H Pns: QOith -rant <ptionR with -rant *ommand gi(es pri(ileges to the user to grant pri(ileges to other userCsD among the pri(ileges he6she has.
'4. OGPT I= P =*G?)P P9" =*G?)P <0?*T=H Pns: P schema is a collection of logical structures of dataA or schema
o/Zects. P schema is owned /y the data/ase user and has the same name as that of user. ?ach user owns a single schema. =chema o/Zects include following type of o/Zects *lustersA "ata/ase MinksA KunctionsA IndeesA @ackagesA @roceduresA =eYuencesA =ynonymsA Ta Ta/lesA /lesA "ata/ase TriggersA TriggersA Niews.
'. G<O T< =TPT8@ =TPT8@ P9" =G8T"<O9 <P*M? "PTP0P=?H "PTP0P=?H Pns: =tartup and =hutdown <racle data/ase can /e done /y only the administator. =tartup is done /y using =TPT8@ command and =hutdown is done /y =G8T"<O9 command
'!. OGPT I= P =?==I<9H Pns: The period /etween Mogin and Mogoff on schema.
'. OGPT I= P *MI?9T @<*?==H OGPT I= P =?N? @<*?==H Pns: ref: 12 & P.
1#1. G<O @M6=M I= "IKK??9T K<) =MH Pns: =M is non5procedural language whereas @M6=M is procedural language that includes features and design of programming language.
1#4. OGPT P? "IKK??9T TB@?= <K @M6=M 0M<*;=H Pns: "?*MP? 0M<*;: In this /lock all the declarations of the (aria/le used in the program is made. If no (aria/les are used this /lock will /ecome optional.
0?-I9 0M<*;: In this /lock all the eecuta/le statements are placed. This /lock is )andatory.
?*?@TI<9 0M<*;: In this /lock all the eceptions are handled. This /lock is also (ery optional.
?9": ?(ery /egin must /e ended with this ?9"W statement.
A!o!+"ou% Na"e -loc&%
49
1#. OGPT P? *<)@<=IT? "PTP TB@?=H Pns: ecordsA Ta/les are two *omposite data types.
1#!. OGPT I= =*<@? <K P NPIP0M? I9 @M6=M 0M<*;H Pns: The (isua/ility and accessi/ility of a (aria/le within the /lockCsD is called scope of a (aria/le.
1#. OGPT I= P 9?=T?" 0M<*;H Pns: P /lock within a /lock is called 9ested 0lock.
1#%. OGPT I= P @M6=M ?9-I9?H Pns: The @M6=M engine accepts any (alid @M6=M /lock as inputA inputA eecutes the procedural procedural part of the statements and sends the =M statements to the =M statement eecutor in the <racle ser(er. ser(er.
11#. OGPT I= "IKK??9*? 0?TO??9 =I)@M? M<<@ P9" P K< M<<@H Pns: =imple reYuires declaration of (aria/les used in it and eit condition /ut Kor Moop doesnFt reYuire this.
111. OGPT I= P *8=<H =T?@= T< 8=? P *8=<H Pns: *ursor is @ri(ate =M area in @M6=M. "eclare the *ursorA * ursorA
<pen the *ursorA Ketch (alues from =M into the local Naria/lesA
50
*lose the *ursor.
112. G<O )P9B TB@?= <K *8=<= P? =8@@<T?" 0B <P*M?H Pns: There are two types of cursors namely Implicit *ursor *ursorAA ?plicit *ursor.
113. OGPT I= P *8=< K< M<<@H Pns: *ursor Kor Moop is shortcut process for ?plicit *ursors /ecause the *ursor is <penA ows are fetched once for each iteration and the cursor is closed automatically when all the rows ha(e /een processed.
11. OGPT I= 8=? <K *8=< OITG ]K< 8@"PT? <K] *MP8=?H Pns: This *lause stop accessing of other users on the particular columns used /y the cursor until the *<))IT is issued.
11!. OGPT I= P9 ?*?@TI<9H G<O IT I= "IKK??9T K<) ?<H Pns: Ohene(er an error occurs ?ception raises. ?rror is a /ug whereas the ?ception is a warning or error condition.
11'. OGPT I= ]<TG?=] ?*?@TI<9H Pns: It is used to along with w ith one or more eception handlers. This will handle all the errors not already handled in the /lock.
12#. OGPT I= =*<@? <K ?*?@TI<9 GP9"MI9- I9 9?=T?" 0M<*;=H Pns: ?ception scope will /e with in that /lock in which eception handler is written.
121. OGPT I= P =805@<-P)H
52
Pns: P =80@<-P) I= P @M6=M 0M<*;A OGI*G OIMM 0? I9N<;?" 0B TP;I9@PP)PT?=.
12. OGPT I= ]I9 <8T] @PP)?T?H Pns: P parameterA which gets (alue into the @rocedure or Kunction and takes the (alue out of the @rocedure or Kunction areaA is called I9 <8T parameter.
12. OGPT I= P @P*;P-? P9" @P*;P-? 0<"BH Pns: @ackage is declarati(e part of the functions and procedures proc edures stored in that package and package /ody is the definition part of the functions and procedures of that package. pac kage.
53
12%. OGPT I= P"NP9TP-? P"NP9TP-? <K @P*;P-? <N? @<*?"8? < K89*TI<9H Pns: @ackages pro(ides Kunctions or @rocedures <(erloading facility and security to those Kunctions or @rocedures.
12'. I= IT @<==I0M? T< GPN? P @<*?"8? P9" P K89*TI<9 OITG TG? =P)? 9P)?H Pns: 9< if it is out side a @ackageA B?= if it is within a @ackage.
131. OGPT I= P TI--?H G<O IT I= "IKK??9T K<) P @<*?"8?H Pns: Trigger: Trigger: P Trigger Trigger is a stored @M6=M program unit associated with a specific data/ase ta/le. @rocedure: P @rocedure is to /e eplicitly called /y the user whereas Triggers Triggers are automatically called implicitly /y <racle itself whene(er e(ent <ccurs.
132. OGPT I= "IKK??9*? 0?TO??9 P TI--? P9" P *<9=TPI9TH Pns: *onstraints are always T8? whereas Triggers are 9<T always T8? and *onstraints has some limitations whereas Trigger has no limitations.
133. OGPT P? "IKK??9T ?N?9T= K< P TI--? P9" TG?I =*<@?=H Pns: InsertA 8pdate or "elete.
54
134. OGPT I= "IKK??9*? 0?TO??9 TP0M? M?N?M P9" <O <O M?N?M TI--?=H Pns: Ta/le Ta/le le(el Triggers eecute once for each ta/le /ased transaction whereas ow le(el Triggers will eecute once K< ?P*G <O.
13. OGPT P? P8T<9<)<8= TI--?=H Pns: =upports to pro(ide *ommit statement in Triggers. Trigg Triggers ers a declared declar ed as independent
Transactions.
13!. OGPT I= P9 ]I9=T?P" <K] TI--?H Pns: These Triggers are used with the *omple Niews only to make possi/le of InsertA 8pdate and "elete on those Niews. Niews .
Ta/le name name is mutati mutatingA ngA trigge trigger6f r6func unctio tion n ma may y not not see it
*ause : P trigger or a user5defined @M6=M function that is referenced in the statement attempted to Yuery or modify a ta/le that was in the middle of /eing modified /y the statement that fired the trigger. Pction : ewrite the trigger or function so it does not read the ta/le.
13'. OG?9 T< 8=? ]:9?O] P9" ]:<M"] =@?*IKI?=H Pns: The prefi :old is used to refer to ( (alues alues already present in the ta/le. The prefi :new is a correlation name that refers to the new (alue that is inserted 6 updated.
55
141. G<O T< *?PT? * ?PT? P 8=?5"?KI9?" NPIP0M? I9 @M6=MH Pns: "efine ( (aria/le aria/le in declaration section
14%. OGPT I= P *<MM?*TI<9 <K <P*M?H Pns: NarrayA 9ested Ta/le Ta/le is a collection c ollection of <racle.
56
14'. OGPT I= "IKK??9*? 0?TO??9 NPPB P9" 9?=T?" TP0M?H Pns: Narray has a fied si+e.
9ested ta/les can carry any num/er of (alues.
1#. G<O T< )<"IKB *<9T?9T= <K P NPPB I9 <P*M?H Pns: To modify a stored NPPB it has to selected s elected into a
@M6=M (aria/le and then inserted /ack into the ta/le.
11. OGPT I= 8=? <K ]TG?] <@?PT< K< 9?=T?" TP0M?H Pns: TG? operator allows nested ta/les to /e manipulated using ")M when it is stored in a Ta/le.
12. OGI*G @P*;P-? I= 8=?" K< KIM? I9@8T6<8T@8T I9 <P*M?H Pns: 8TM7KIM? @ackage is used for Kile input6output in <racle.
13. 9P)? =<)? )?TG<"= P9" @<*?"8?= <K KIM? I6< @P*;P-?H Pns: K<@?9A K*M<=?A KKM8=GA I=7<@?9A -?T7MI9?A @8T7MI9?A @8TKA @8TKA 9?O7MI9? 14. OGPT I= =MH G<O IT I= "IKK??9T K<) "0* *<99?*TINITBH Pns: =M is /asically a a(a program containing em/edded static =M statements that are compati/le with a(a design philosophy. philosophy.
1. OGPT I= P9 IT?PT<H 9ame some TB@?= <K IT?PT<=H
57
Pns: =M Iterators are /asically record groups generated during transactionA which reYuires manipulation of more than one records from one or more ta/les. There are two types Iterators namely 9amed Iterator and @ositional Iterator.
1. OGPT I= TP0M? @PTITI<9I9- P9" I9"? @PTITI<9I9-H Pns: <racle% allows ta/les and Indees to /e partitioned or /roken up into smaller parts /ased on range of key (alues. @artitioning is a Qdi(ide and conYuerR strategy that impro(es administration and performance in data warehouse and <MT@ systems.
1'. OGPT I= @GB=I*PM )?)<B =T8*T8? <K <P*M?H Pns: The /asic oracle memory structure associated with <racle includes: =oftware *ode Preas The =ystem -lo/al Prea C=-PD AThe "ata/ase 0uffer *ache The shared @oolA The @rogram -lo/al Preas C@-PDA =tack Preas A"ata PreasA =ort Preas
1!1. OGPT I= GAH Pns: P =ystem -lo/al Prea is a group of shared memory allocated /y <racle that contains data and control information for one <racle data/ase instance. IK the multiple users are concurrently connected to the same instanceA the data in the instanceFs =-P is QsharedR among the users. *onseYuentlyAA the =-P is often referred to as either the Qsystem -lo/al PreaR or the *onseYuently Q=hared -lo/al PreaR.
58
1!2. OGPT I= PGAH Pns: The @rogram -lo/al Prea is a memory /uffer that contains data and control information for a ser(er process. P @-P is created /y <racle when a ser(er process is started. The information in a @-P depends on the configuration of <racle.
1!3. OGPT I= P9 <P*M? I9=TP9*?H Pns: ?(ery time a data/ase is startedA an =-P is allocated and <racle /ackground processes are started. The com/ination of these processes and memory /uffers is called an <racle instance.
1!4. OGPT P? "IKK??9T <P*M? @<*?==?=H Pns: P process is a Qthread of controlR or a mechanism in an operating system that can /e eecute a series of steps. =ome operating systems use terms Zo/s or
task. P process normally has its own pri(ate memory area in which it runs. Pn <racle data/ase system has general types of process: 8ser @rocesses and <racle @rocesses.
1!. OGPT I= "IKK??9*? 0?TO??9 @)<9 P9" =)<9H Pns: =)<9 C=ystem )onitorD performs instance reco(ery at instance of startup. In a multiple instance system Cone that uses the parallel ser(erDA =)<9 of one instance can also perform instance reco(ery other instance that ha(e failed whereas The @)<9 C@rocess )onitorD performs process reco(ery when a user process fails.
1!!. OGPT I= "IKK??9*? 0?TO??9 "PTP0P=? "PTP0P=? P9" TP0M?=@P TP0M?=@P*?H *?H Pns: "ata/ase is a p physical hysical *omponent *omponent
Pns: The "ata 0ase Oriter writes modified /locks from the data/ase /uffer cache to the data files.
1!%. OGPT I= <0 <K M<- OIT? CM-OD @<*==H Pns: The Mog Oriter writes redo log files to disk. edo log data is generated in the redo log /uffer of the =-P. Ps transactions commit and log /uffer fillsA M-O writes redo entries into an online redo log file.
1!'. OGPT I= ?*<N??H Pns: The eco(er C?*<D is used to resol(e distri/uted transactions that are pending due to network or system failure in a distri/uted data/ase. data/ase . Pt timed inter(alsA the local ?*< attempts to concept to remote data/ase and a nd automatically complete the commit or roll/ack of the local portion of any pending distri/uted transactions.
1#. OGPT I= P*GIN?H Pns: The Prchi(er CP*GD copies the onlin online e redo log files to archi(al storage when they are full. AP*G is acti(e only when a data/aseFs redo log is used P*GIM<- mode.
11. OGPT I= P =T<?" = T<?" 8?BH Pns: NI?O
12. OGPT I= 8=? @<*?== P9" =?N? @<*?==H Pns: P 8ser process is created and maintained to eecute the software code of an application program Csuch as @< @rogramD or an <P*M? tool Csuch as =M "0PD. The 8ser process also manages the communication with ser(er processes. 8ser processes process es communication with the ser(er @rocesses through the program interface.
<ther processes call <P*M? processes. In a dedicated ser(er configurationA a ser(er @rocess handles reYuests for a single user process. P multithread
60
ser(er configuration allows many user processes to share a small num/er of ser(er processesA minimi+ing the utili+ation of a(aila/le system resources.
13. OGPT I= P =?MK ?K??9TIPM I9T?-ITBH Pns: Ta/le Ta/le related to itself .Koreign key of the ta/le ta/le links to primary key of the same ta/le.
14. OGPT I= P ]PI=?] =TPT =TPT?)?9TH ?)?9TH Pns: It is used to aise ?ceptions.
1. OGPT I= <OI"H G<O IT I= "IKK??9T K<) <O98)H Pns: owid is the address of the row r ow at where it is stored in the data/ase. ownum is count of records whereas owid is identification of the each row.
QQQ All The -e%t 3 ;#DA; QQQ 'i features:
'i oins: =upports P9=I6I=< standard =Yl 1''' synta )ade easy for Pppln s6w tools to understand =Yl ueries 1. 9atural oin 2. oin oin wi with th 8s 8sin ing g 3. oin with <9 4. Inner oin
. Meft outer Zoin !. ig ight ou oute terr Zoi Zoin n . Kull outer Zoin %. *ross Zoin
1. select s elect empnoAenameAsalAZo/AdeptnoAdnameAloc empnoAenameAsalAZo/AdeptnoAdnameAloc
from emp natural Zoin deptW
61
2. select s elect empnoAenameAsalAZo/AdeptnoAdnameAloc empnoAenameAsalAZo/AdeptnoAdnameAloc
from emp Zoin dept usingCdeptnoDW
3. select e.empnoA e.enameA e.salA e.Zo/A e.deptnoAd.dnameA d.loc from emp e oin dept d
onCe.deptno [ d.deptnoD W
4. select e.empnoA e.enameA e.salA e.Zo/A e.deptnoA d.dnameA d.loc from emp e Inner oin dept d onCe.deptno [ d.deptnoD W
. select e.empnoA e.enameA e.salA e.Zo/A e.deptnoA d.dnameA d.loc from emp e left outer Zoin dept d onCe.deptno [ d.deptnoD W
!. select e.empnoA e.enameA e.salA e.Zo/A e.deptnoAd.dnameA d.loc from emp e right outer Zoin dept d onCe.deptno [ d.deptnoD W
. select e.empnoA e.enameA e.salA e.Zo/A e.deptnoAd.dnameA d.loc from emp e full outer Zoin dept d onCe.deptno [ d.deptnoD W left outer Zoin union right outer Zoin [ full outer Zoin
%. select s elect empnoAenameAsalAZo/AdeptnoAdnameAloc empnoAenameAsalAZo/AdeptnoAdnameAloc
=ystimestamp : -i(es date and time including fractional seconds in =?N? time +one current7timestamp: -i(es date and time including fractional seconds in *MI?9T time +one sysdate: -i(es only date in ser(er ser(er time +one current7date: -i(es only date in client time +one ?tract : 8sed to retrie(e a particular (alue from the gi(en month 6 year D.
date
C day 6
to7timestampCdD : *on(erts gi(en date into date & time information with am 6 pm . d/time+one : -i(es ser(er time +one (alue Timestamp : "ata type Putomatically stores date and time information with am 6 pm .
select systimestamp A current7timestamp from dualW select sysdateAcurrent7date from dualW select d/time+one from dualW select to7timestampCsysdateD from dualW 2#5Zan5#' !:4%:23 pm select etractCday from sysdateD A etractCmonth from sysdateDA etractCyear from sysdateD from dualW
create ta/le temp Cc1 timestampDW insert into temp (aluesCsysdateDW select from tempW 2#5Zan5#' !:2:23 pm 5555555555555555555555555555555555555555555555555555555555555555555555555555 9ew -eneral Kunctions: *oalesceCepr1Aepr2Aepr3A.......D 555 @icks the first not null epression result .
63
nullif C epr1Aepr2 D 555 If epr1 and epr2 results are same it returns 98MM (alue otherwise it return epr1 result. 9(l2Cepr1Aepr2Aepr3D 555 If epr1 is null it manipulates epr3 Aif epr1 is not null it manipulates epr2.
select coalesceC1## > nullA 12% 5 null > 1###A 12 nullA
22A 234A'%%'D from dualW 55 22
select enameA Zo/A coalesce Ccomm 2A sal 1.D /onus from empW
select rollA nameA nullifCfeeA2##D from student where course [ _<racle'i_W
select enameA Zo/A n(l2CcommAsal > commAsalD net from empW 555555555555555555555555555555555555555555555555555555555555555555555555555 )utiple Inserts: =upports to insert into more than 1 ta/le at a time. 0ut input must /e retrie(ed from eisting ta/le.
?: )ake 3 empty ta/les same as "ept ta/le. *reate ta/le "1 as select from dept where rownum is nullW *reate ta/le "2 as select from dept where rownum is nullW
64
*reate ta/le "3 as select from dept where rownum is nullW
insert into "1 select from deptW insert into "2 select from deptW insert into "3 select from deptW
insert all into "1 (aluesCdeptnoAdnameAlocD into "2 (aluesCdeptnoAdnameAlocD into "3 (aluesCdeptnoAdnameAlocD select from deptW
*onditional Insert: insert all when Cdeptno S[ 4#D then into "1 (aluesCdeptnoAdnameAlocD when Cdeptno S[ '#D then into "2 (aluesCdeptnoAdnameAlocD else into "3CdnameAlocD (aluesCdnameAlocD select from deptW
insert all when course [ _<racle'i_ then into stu7oracle (aluesCrollAnameAfeeD when course [ _d!i_ then
65
into stu7d!i (aluesCrollAnameAfeeD when course [ _uni_ then into stu7uni (aluesCrollAnameAfeeD select from studentW
=tudent
stu7oracle
555555555
555555555555
oll
oll
name
name
course
fee
fee 5555555555555555555555555555555555555555555555555555555555555555555555555555 )erge : 8sed to compare the 2 ta/le contents and makes them eYual. It supports only 8pdate and Insert operations .