Complete Unix Commands

Published on July 2020 | Categories: Documents | Downloads: 5 | Comments: 0 | Views: 138
of 66
Download PDF   Embed   Report

Comments

Content

 

1

 

2

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 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.tt

Du %& ile!a"e( ile!a"e2 ). ' to find si+e of multiple files "u ,sk test.tt test2.tt

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%1oler %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!%ier %i/e o irector+ while calcualati!g

 

3

E:files in dsdu 5h  

120 .6In 0ound6testing789I

  14.#;0 .6In 0ound   13.#;0 .6<ut 0ound   32.##;0 .

ow to i! all the ile% i! all the irectorie% i! that oler7 uo%e 1ile% i! D% i% the oler which ha% %o "a!+ ile% a! al%o 2 1oler% #! -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%e7 L% ; 

  =yn: $which pwd 13. <at data to the eiting files

: is use to create new files or to open eiting files or to append

<reate: cat filename 55555555555 55555555555cntl>d

;eirect' cat file1 file2 file3 file455555555 reirect outut Ae!: cat filename55555555 %i!gle ile  files

$cat file1 file2 file3 ?)@555555 "ulti

55555555555 55555555555cntl>d

Oe! ile' cat =ile!a"e33333  oe! %i!gle file "ulti files

$cat file1A file2A file35555555555 to oe!

 

4

*at .filename555555555for hie! files 14. Touch

: It is used to create an empty file i.e. # /yte file

=B9: $ touch filename $ touch file1 file2 file3555555555  create multiple files 1. r"

: deleting files or directories ? rm filename5555555555555555deleting single file rm 5i filename55555555555555deleting files with confirmation rm file1 file25555555555555555deleting multiple files rmdir dirname55555555555555deleting 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 555555555555555555555it delets whose file name starts with EtF  Gow to delete the directory which is not emptyH ?: m ,r Testing78ni. 1!. "&ir

 : creating directories

=yn: $mkdir dirname =ys: $)kdir .dirname555555555555hidden directory 1. <

: 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 J5555555555555555555555555it changes to home directory

1%. c

:copy source file to target file

? *p emp1 emp25555555555555555555555emp1 tp 2 coping *p ,I m1 m25555555555555555555555555o(erwrite confirmationH B *p , source directory to target directory5555555cp , a/c y+ 1'. ">

: it is used to rename or mo(e file

?: m( eiting filename new filename    

)( emp .emp55555555555555 .emp5555555555555555555555 55555555



to hide

)( .emp emp55555555555555555555 emp55555555555555 555555 to unhide

2#.l%

: 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 .ee 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 dsIn 0oundcmp type1.tt type2.tt type type1. 1.t ttt ty type pe2. 2.t ttt diff differ er

r: cha charr 2A 2A 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 filename5555it 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 filename555555555555555it 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

EF55555555it matches E#F or more chars

iiD iiD EHF EHF 55 5555 5555 5555it matches any single chars iiiD 

 555it matches any single chars in the gi(en list

i( i(DD E,E5 E,E5555 55555 55it matches any single char in the gi(en range 1D ls t55 t55555 555555 555555 555555 55555it list the files starts with EtF  2D ls s 555555 555555555 55555 5555 55it list the files that ends with E=F 

3D ls /k /k55555 5555555 55555 555555 55555it list the files starts with E/F and ends with EkF  4D ls aH555 aH555555 555555 555555 55555 55it list the 2 characters filename 1 st later fallowed /y EaF and second letter is any one character

D ls/ ls/kn knt t555 555555 555555 55555 55it list the files starts with E/F or EkF or EnF or EtF  !D ls a/c a/cdef defgh gh or ls lsa5h a5h55 55list the filesA first char /6w EaF to EhF 

D ls /5 /5k kp5t p5td5n d5n55 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.tt and lsP?I<8.tt /oth will gi(e the same result 3%. gre

: glo/ally search a regular epression and print it

Is used for to search a string or regular epression 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

 

Q

(D $grep Qtechno softR sample

gre c" otio!% $ grep ,i techno sample55555555555555555555555 ignore case sensiti(e $ grep ,c techno sample55555555555555555555555



count no of lines

$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 exre%%io!' any string contains wildcard charctor knows as regular epression 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 sample555i.e. or matches any single charctor

Wor atter! :6S  

6

6S 5555555start of the word  6555555 end of the word

 

9

-rep Q6Stechno6R sample 555555555555o6p: techno -rep Q6StechnoR sample5555555555555555o6p: techno soft  

55555555555555555o6p: techno 123

-rep Qtechno6R sample

5555 o6p: hellotechnoA a/ctechno

-rep Q6S #5'#5'#5'#5'6R sample55555555555555 it display 4 digits Ci.e.1234A 4!D

Li!e atter!' B3333333333starts of the file  

$5555555555ends of the file

?: grep QdR sample555555555555555it display the line starts withEdF   

-rep QtheR sample55555555555555555 sample5555555555555 5555it list the lines start with EtheF 

 

-rep Q6Sthe6R simple 5555555555 sample the line eactly 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 /ktR sample555555555555 list the line starting with E/F or Ek EorFtF  EorF tF  -rep Q /ktR sample5555555555 list the line which is not start with E/F or EkF orEtF  -rep QR89I$R sample 555555555display the line ha(ing only word E8niF  -rep QU. $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.AVA$ -rep Q$R sample55555555555555 it list empty lines -rep ,c Q$R sample5555555555counts 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 sample5555555555555555555here /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.tt This command is used to show the 0efore 3 lines when the string is found -rep ,0 3 ,I QseR emp.tt If the no.of lines found are not eactly same as the lines found then it will result the lines that it found.

3'. gre epression  

$grep Qhello

   

: it is used for search multiple strings /ut it doesnFt allow to search regular

techno 89IRsample5555555555it searches for hello or techno str 89I

4#. egre 

: it is com/ination of grep and fgrep

  $egrep Qhello   hello 89IRsample 41. e

$egrep Q$R sample

: to replace a string

$ sed Qs6eisting string6new string6gR filename55sed is used to find and replace and grep is for find print Gere g is to state that replace eisting string with new string -lo/ally. If we want to replace only second instance then =ed Qs6 eisting string6new string62R  Oe can use any delimiter to replace the command =ed QsV eisting stringV new string VgR  Oe can replace the string in only one particular line =ed Q3 sV eisting stringV new string VgR 

 

11

Oe can replace range of lines /y using /elow command =ed Q1A3 sV eisting stringV new string VgR 

Oe can find any no.of lines 2 times /y using sed command =ed EpF emp.tt 5 This will print all lines 2 times Oe can print only particular lines of a file =ed ,n E1pW$pF emp.tt Oe can delete lines /y usin sed =ed E2 dF emp.tt

"elete

=ed E1dW $d E em emp.tt p.tt =ed E1A dF emp.tt

2 line

"elete

"elete

1 and last line

the line range from 1 to .

iD $sed Qs68ni6Minu6gi Qmadha(: 5555555555555 Ei Efor case sensiti(e iiD $sed Qs68ni6Minu6giR5555555555555555555555  whate(er lines starting with 89I are replaced /y Minu iiiD $sed Qs6$6I like 8ni6g IR sample55555555 empty string are filled with EI like 89IFF  i(D $=ed Qs68ni66g 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<8RSsample5555replace char /y char iiiD tr QAR QltR Semp5555555555555555 whene(er QAR is there replace with ta/ space

 

i(D tr Qa5+R QP5X S=i(a55555555  con(erts hole file into uppercase

43D <ut

: it is used for to retrie(e reYuired fields and characters from a gi(en file

 

12

?: madha( is good /oy551% chars *ut ,f 25 madha(555o6p: adha *ut ,c 151# madha( *ut ,c 51#A 152# madha(5555555 for e(ery line 51#A 152# characters *ut ,c 1A2A3 emp.tt

@rints

*ut ,c 153A45! emp.tt *ut ,c1#5 emp.tt

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.tt

This

will print the 2nd word of each line /y taking EAF as

delimiter. *ut ,dFAF ,f2A3A emp.tt

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.ttV 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 citiestr

P@

Gydera/ad

P@: Gydera/ad

Tamilnadu

madras

Tamilnadu: madras

;arnataka

0angalore

;arnataka: 0angalore

;erala

Tri(andrum

)aharashtra

0om/ay

4D ort : it is used for to sort the file content. 0y default it sorts file contents /ased on P=*II (alues5default is ascending =ort sample iD sort ,r sample555555displays descending order

 

13

iiD sort ,u sample55555 it displays uniYue lines in the gi(en file iiiD sort ,n file5555F9R numeric comparisons i(D sort ,nur file (D sort sample temp $m( temp sample

orti!g the ata iel 9+ iel >pos55starting field 5@os55ending field CoptionalD iD =ort ,f >pas1 ,pas2 filename iiD =ort ,f >1 53 filename55555 starting from end /efore 3 iiiD =ort ,fn >2 53 file 555555 it gi(es only num/ers 4!D C!i order

: it displays uniYue lines in the gi(en file /ut the file contents should /e in sort

?:file1

iD $ uniY file

iiD $uniY ,u filename55it eliminates duplicates

Paaaaa Paaaaa

Paaaaa

ccccc

Paaaaa

cccccccc

ddddd

*cccccc

dddddd

@pppp

"dddd

hhhhhh

ttttttt

Ghhhh

pppppp

Ghhhh

ttttttttt

@pppp Ttttttt iiiD $ 8niY ,d filename5555displays only duplicated lines

IND uniY ,c filename55555it counts

how many times lines duplicated

   

Paaaaa555552 *ccccccc55551

 

14

ND $ uniY ,u file temp $ m( temp filename "elete duplicated lines from file

"dddd555551 Ghhhhh5552 @pppp555551 Ttttttt555551

4Dii!g?@  side cmd as i6p

: 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 ,l555555555555displays total no of su/directories in the current directory iiiD ls ,l Vgrep QdR5555 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 %criti!g' It is group of 89I commands and shell keywords The main concept of shell scripting is to handle tet files ID -ou!e %hell5555stea(e 0ourne 55555$55555555sh555 Csh as i!terreter@ ii@ -a%h %hell C/orne again shellD 555same as a/o(e55ad(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 eecuted eecuted commands

II@ Echo

: it display the string on screen scree n CmonitorD

1ile er"i%%io!%'xxxxxxxxx@ C%erow!er333er"i%%io!% C%erow!er333er "i%%io!%

ir%t art@

Grou er"i%%io!%

%eco! art@

Other er"i%%io!%

thir art@

J333 a er"i%%io!% to ugo 9ut it oe% !ot elete exiti!g er"i%%io!@ 333 e!+ er"i%%io!%@ K3333 a%%ig! er"i%%io!% a er"i%%io!% to ugo 9ut it elete exiti!g er"i%%io!@@ rw56rw56r55 555555555"efault permissions for regular files rw6rw6r5555555555 default permission for directories !D ch"o

: it is used for to change file permissions

=yn: $chmod who6 >656[6 iD ls ,l filename5555555 rw5 rw5

rL

iiD chmod g> filename55555rw5 rw rL iiiD chmod u>A g5w filename555555rw r5 rL iND chmod g[w filename55555 rw ,w5 rL

Octal coe ;ea333333F Write333332 Execute( $chmod ! filename5555555rw r5 rw5 $chmod !42 filename5555rw5 r55 5w5 D chow!

  : to change change owner name of the file file

\chown owner name filename

 

16

%@ 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 should /e logged into the

$write techno2 Gello

iiD $mesg n55deny the msg iiiD mesg y5to 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 ,k555it displays the disk space in /ytes

 

iiD df ,h555it displays disk space in kilo /ytes

 

iiiD df ,g555it displays the disk space in giga /ytes

!3Du  :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 filename5555o6p: filename.g+ To *reate multiple Xip files to a single Xip file we use /elow command Xip my+ip.+ip emp.tt 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 55555transfer files from one ser(er to another  

$ ftp ipaddress

Mogin: 5555555 @assword: 555555 Ktpls Cser(erD KtpVlsCclientD Ktpget filename Cto download a fileD Ktpmget file1 file255555 Cto download multi filesD Ktpput filename Cto upload a fileD Ktpmput file1 file255555 Cto upload multi filesD D1t: to transfer files from one ser(er user account to another ser(er user account   $su root 55to 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 1first mail 2second mail reading &2 it Yuickly opens second mail &Y55Yuit from mail /o &w to sa(e mail contents to a file &pprint mail contents &r55replays &d5delete mails %@$"ail  :to :to read mails send to secondary mail/o 'D e"ac%

:full screen editor

%#@ echo

: echo the tet string to on monitor

%1D ile 

: classify the file type

 

19

%2D exr

: 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

%Dlr:l 

:print to defind printer

%%D lr": 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=*IIAheAdecimal or char

'1Da%%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 %crit ile eecuted

: sa(es e(erything that appears on the screen to file until eit is

'D %ource ile

: read cmds from the file and a nd eecute 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 uuecoe ile

: decode a uuencoded fileA recreating the original file

1#1D uue!coe !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 iere!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 II555555 =ilicon -raphics.

What are the iere!t %ecurit+ eature% i! C!ix7

 

1. @assword protection. 2. Kile permissions. 3. ?ncryption.

What,% the co""a! to i! out toa+,% ate7 date

What,% the co""a! to i! out u%er% o! the %+%te"7

 

21

 who

ow o +ou i! out the curre!t irector+ +ou,re i!7 pwd

What i% the co""a! to %ee the locatio! o co""a!7 Ohere is Scommand name

ow o +ou i! out +our ow! u%er!a"e7 Ohoami

CorD log name

ow to clo%e the curre!t u%er accou!t7 ?it

ow to create e"t+ ile7 Touch Sfilename

ow o +ou re"o>e a ile7 m Sfilename

ow to oi! "ultiile ile% >erticall+7 *at

file1 file2 file3 UU

The ile or which we o !ot ha>e write er"i%%io! ca! 9e elete u%i!g the co""a!7 rm 5f Sfilename

ow o +ou re"o>e a irector+ a! it% %u9irectorie%7  rm ,rf Sdirectoryname

ow to re!a"e a ile7 )( Sfilename

ow to co+ "ultile ile% a! irectorie% i!to %o"e other irector+7 cp 5r source7directory destination7directory ow to %ee hoe! ile%7 Ms ,a

ow to %ee ile% a! %u9irectorie% 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 ie!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 iere!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 iere!ce 9etwee! a %ot 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 iere!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. catfilename

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 ecept enter key character what i% the outut 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

ow o +ou cou!t wor%: li!e% a! character% i! a ile7 Oc Sfilename

which co""a! i% u%e to ie!ti+ the t+e o the ile7 file

 

23

gre "ea!% -lo/ally search a regular epression and print it

ow o +ou %earch or a %tri!g i!%ie a gi>e! ile7 grep string filename

ow o +ou %earch or a %tri!g i!%ie a curre!t irector+7 grep string 

ow o +ou %earch or a %tri!g i! a irector+ with the %u9irectorie% recur%e7  grep 5r string 

Diere!ce 9etwee! gre: egre a! gre

grep : does not accept more then one epression

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 epressions only strings. It is faster than the other two and should /e used when using fied 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

ow to re"o>e E"t+ li!e% or" a gi>e! ile7

 

24

-rep ,( Q$R filename  temfilename )( tempfilename filename

What i% atter! to %earch F igit wor i! a ile7 -rep QS#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!iue li!e% ro" a gi>e! ile7 =ort ,u filename

ow to eli"i!ate co"letel+ ulicate li!e% ro" a gi>e! ile7 8niY ,u filename ow to re"o>e all ulicate 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 caital letter% o a ile te%t i!to lower ca%e7 cat filename V tr ]P5X] ]a5+]

The ieli!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 ieli!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 ecept ecept 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 outut o ollowi!g co""a!7 echo STec!o%otR ? wc c '

What i% the eault u"a%&7 #22

 

26

What i% the eault 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 eault ile er"i%%io!% whe! ile% are create7 8mask

Exlai! 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 eecute programs or shells from the directory.

What i% ch"o: chow! a! chgr7 *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 eit 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! reuire7 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%: excet 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! ater exiti!g the %hell what i% the co""a! u%e7 9ohup

 which co""a! will get execute e>e! ater +ou log out7  9ohup

which %ig!al ca!!ot 9e trae7 kill ,'

ow to reirect %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 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!7 Oall

What i% the co""a! to %e! "ail to other u%er7 )ail username

ow to oe! %eco!ar+ "ail 9ox7 )ail 5f 

What o +ou o i +ou o!Vt wa!t to 9e i!terrute 9+ other u%er%V "e%%age%7

 

28

Pns. mesg n

hell criti!g #!ter>iew ue%tio!%

Diere!ce 9etwee! the outut 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 %crit aart ro" u%i!g %h co""a! a! ch"o7 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 %crit !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 reaa9ilit+: 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 coe 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 eecuted. eecuted. Kor eampleA 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.

3.

OG OGP PT I= I= P " "P PTP0P=? 0P=? )P9P )P9P-? -?)? )?9T 9T =B=T =B=T?) ?) C"0) C"0)=D =D @P @P*; *;PP-?H ?H

Pns: The *ollection of Interrelated "ata and some @rograms to access the "ata is *alled "ata 0ase )anagement =ystem C"0)=D.

4.

OG?9 *P *P9 O? O? = =P PB P "0)= @P @P*;P-? P= " "0)=H

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.

.

OG OGPT PT P? P? GI? GI?P P*G *GI*P I*PMA MA 9?TO< 9?TO<; ;AA P9" P9" ?M ?MPT PTI< I<9P 9PM M "PT "PTP0 P0P= P=? ? ) )<" <"?M ?M=H =H

Pns: aD ierarchical Moel' 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& Moel' 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 epanded 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 eists /etween the parent and child.

cD ;elatio!al Moel' The elational "ata/ase )odel eliminates the need

 

31

for eplicit 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.

'.

"? "?KI KI9? 9? ?9TI ?9TITB TBAA PTTI0 TI08T 8T? ? P9" P9" ?M ?MP PTI<9= I<9=GI GI@ @.

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 eists /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.

12. 12.

OGP OGPT P? P? NPI NPI<8 <8= =9 9< <)P )PM M K< K<)= )= <K "PT "PTPH

Pns: The The Kirst 9ormal Korm 19KA 19KA Th The e =eco =econd nd 9orm 9ormal al Ko Korm rm

29K 29KA

 

32

The Third 9ormal Korm

39KA

The 0oy 0oyce ce and and *od *odd d 9ormal 9ormal Korm Korm 0* 9K. 9K.

13.

OGPT I= I= " "? ?9<)P )PMIXPT XPTI<9H

Pns: The intentional introduction of redundancy to a ta/le to impro(e performance is called "?9<)PMIXPTI<9.

14.

OGPT OGPT P? P? 15TI 15TI?A ?A 25T 25TI? I?AA 35TI 35TI? ? < < 95TI 95TI? ? "PT "PTP0 P0P=? P=? P P*GI *GIT?*T T?*T8? 8?=H =H

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.

1! 1!..

OGPT OGPT I= "IK "IKK? K?? ?9*? 9*? 0?TO 0?TO?? ??9 9 P @< @<*? *?"8 "8PM PM MP MP9-8 9-8PP-? ? P9" P9" P

9<95@<*?"8PM 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.

1%.. 1%

*MP= *MP==I =IKI KI*P *PT TI< I<9 9 <K <K =M =M *<)) *<))P9 P9"= "=H H

Pns: ""M "" M C"at C"ata a "efin "efinit itio ion n Ma Mang ngua uage geDD

"M "M "at "ata a uer ueryi ying ng Mna Mnagu guag age e

")M C"ata )anipulating ManguageD "*M C"ata *ontrol ManguageD ManguageD T*MC"ata Transaction ManguageD

*reate Plter "rop Truncate Truncate enameA =elect A Insert 8pdate "elete )erge )erge A -rant e(oke A oll/ack *ommit sa(epoint   1' 1'..

OGPT OGPT I= "I "IKK KK? ??9 ?9*? *? 0?TO 0?TO?? ??9 9 ""M ""M P9" P9" ")M ")M *<)) *<))P9" P9"=H =H

Pns: Kor ""M commands autocommit is <9 implicitly whereas Kor ")M commands autocommit is to /e turned <9 eplicitly.

2# 2#..

OGPT OGPT I= "I "IKK KK? ??9 ?9*? *? 0?T 0?TO? O??9 ?9 P TP9 TP9=P =P*TI *TI<9 <9 P9" P9" P 8? 8?BH BH

Pns: P Transaction is unit of some commands where as uery is a single line reYuest for the information from the data/ase.

21 21..

OGPT OGPT I= "IK "IKK? K?? ?9*? 9*? 0 0?T ?TO? O??9 ?9 T T8 89* 9*PT PT? ? P9" P9" "? "?M? M?T? T? *<) *<))P )P9" 9"=H =H

 

34

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.

22 22..

OGPT OGPT I= "IK "IKK? K?? ?9*? 9*? 0?TO 0?TO?? ??9 9 8@"P 8@"PT? T? P9" P9" PM PMT? T? *<)) *<))P9" P9"=H =H

Pns: Plter command is used to modify the data/ase o/Zects where as the 8pdate command is used to modify the (alues of a data /ase o/Zects.

23. 23.

OGP OGPT P P? ? *<)) *<))P9 P9"= "= <K "*M "*M *P *PT T??-< <BH BH

Pns: -rant and e(oke are the two commands /elong to the "*M *ategory.   24 24..

OGI*G OGI*G I= P P9 9 ?KKI ?KKI*I *I?9 ?9T T *<)) *<))P9" P9" 5 T89 T89*P *PT? T? < "?M "?M?T ?T?H ?H OGB OGBH H

Pns: "elete is the efficient command /ecause using this command we can delete only those records that are not really rea lly reYuired.

2. 2.

OGP OGPT P? P?  8M 8M?= ?= K< K< 9 9P) P)I9 I9- P TP TP0M? 0M? < < *<M *<M8) 8)9H 9H

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

 

35

Pns: P Ta/le can ha(e 1### columns.

2 2..

OGPT OGPT P? P? "IK "IKK? K?? ?9T 9T " "PT PTP PTB@? TB@?= = =8@ =8@@< @<T? T?" " 0B 0B = =MH MH

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.

2% 2%..

OGPT OGPT I= "IK "IKK? K?? ?9*? 9*? 0?TO 0?TO?? ??9 9 M<9M<9- P9" P9" M<0 M<0 "PT "PTP PTB@? TB@?=H =H

Pns: M<0

M<9-

1D The maimum si+e is 4-0. 2D M<0s Cecept 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 maimum 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

2' 2'..

OGPT OGPT I= "IK "IKK? K?? ?9*? 9*? 0 0?T ?TO? O??9 ?9 * *GP GP  P9" NP NP*G *GP2 P2 "PT "PTP PTB@? TB@?=H =H

Pns: Narchar2 is similar to *har /ut can store (aria/le no. <f characters and while Yuerying the the ta/le (archar2 trims the etra spaces from the column and fetches the rows that eactly match the criteria.

 

36

3#. G<O )8*G )?)<B I= PMM<*PT?" K< "PT? "PTPTB@?H "PTPTB@?H OGPT I= "?KP8MT "PT? K<)PT I9 <P*M?H

Pns: Kor "ate data type oracle allocates  /ytes )emory. "efault "ate Kormat is: ""5)<95BB.

31. 31.

OGP OGPT I= I=  P9 P9-? -? K< K< ? ?P* P*G G "P "PTPTB@ B@? ? <K <K = =M MH H

Pns: "atatype *har

ange

Narchar2 9um/er

Kloat

M<9-A POA POA M<9-PO Marge </Zects

CM<0FsD 2### /ytes 4### /ytes @recision 1 to 3% =cale 5%4 to 12 @recision 3% decimals <r 122 /inary /inary precision

32.

2 -0 4-0

G<O T< ?9P)? P *<M8)9H

Pns: Oe canFt rename a *olumn of a ta/le directly. =o we follow the following steps. To ename a *olumn: aD

Plte Plterr th the e tta/ a/le le speci specify fyin ing g new new colu column mn na name me to /e gi gi(e (en n and and dat data a typ type. e.

/D

Then Then copy copy th the e (al (alue ues s iin n the the colu column mn to /e renam renamed ed in into to ne new w col colum umn. n.

cD

drop the old column.

33 33..

G<O T< "?*? "?*?P=? P=? =I =IX? X? < < *GP9 *GP9-? -? "PT "PTP PTB@? TB@? <K <K P * *<M <M8) 8)9H 9H

Pns: To "ecrease "ecrease the si+e of a "ata type of a column i.

Truncate the ta/le first.

ii. ii.

Plte Plterr tthe he ta ta/l /le e col colum umn n who whose se si+ si+e e is is tto o /e /e dec decrea reased sed usin using g tthe he same same

 

37

name and data type /ut new si+e.

34 34..

OGPT OGPT I= P *<9= *<9=TP TPI9 I9TH TH OGP OGPT T P? P? IT= IT= NPI< NPI<8= 8= M? M?N? N?M=H M=H

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.

MI=T MI=T <8T <8T PMM PMM T TG? G? * *<9 <9=T =TP PI9 I9T= T= =8@ =8@@< @<T T?" ?" 0B 0B =M. =M.

Pns: 9ot 9ullA 8niYueA *heckA @rimary ;ey and Koreign ;ey or eferential Integrity.

3! 3!..

OGPT OGPT I= "IK "IKK? K?? ?9*? 9*? 0 0?T ?TO? O??9 ?9 8 89I 9I8 8?> ?>9< 9<T T 98MM 98MM P9 P9" " @I) @I)P PB B ;? ;?BH BH

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 PB B ;?B ;?BH H

Pns: P @rimary key created on com/ination of columns is called *omposite @rimary ;ey.

3% 3%..

OGPT OGPT I= P *P9" *P9"I" I"PT PT? ? *<M8 *<M8)9 )9H H G<O )P9B )P9B *P9" *P9"I" I"PT PT? ? *< *<M8 M8)9 )9= = *P9 0? 0?

@<==I0M? @? *<)@<=IT? @I)PB ;?BH Pns: It is a part of composite primary key. )aimum 32 candidate key can /e there in composite primary key.   3'.

G<O T< "?KI9? P 98M 98MM NP NPM8?H

Pns: P 98MM (alue is something which is una(aila/leA it is neither +ero nor a space and any mathematical calculation with 98MM is always 98MM.

 

38

4#. OGPT I= 98MMH P *<9=TPI9T < "?KP8MT "?KP8MT NPM8?H NPM8?H Pns: It is a default (alue.

41. OGPT I= "?KP8MT "?KP8MT NPM8? K< ?N?B *<M8)9 <K P TP0M?H Pns: 98MM.

42. OGPT I= *?PT?" I)@MI*ITMB K< ?N?B 89I8? P9" @I)PB @ I)PB ;?B *<M8)9=H Pns: Inde.

43. OGPT P? MI)ITPTI<9= MI)ITPTI<9= <K *G?*; *G ?*; *<9=TPI9TH 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=TPI9TH 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 .

 

39

4. G<O T< "<@ P @P?9T TP0M? OG?9 ITF= *GIM" TP0M? ?I=T=H Pns: 8sing ]on delete cascade].

4%. I= <P*M? *P=? =?9=ITIN?H Pns: 9<

4'. G<O <P*M? I"?9TIKI?= ?P*G ?*<" <K TP0M? 89I8?MBH 89I8?MBH Pns: 0y *reating indees and reference I"s.

#. OGPT I= P @=?8"<5*<M8)9H 9P)? =<)? @=?8"<5*<M8)9= <K <P*M?H Pns: *olumns that are not created eplicitly e plicitly /y the user and can /e used eplicitly eplicitly in Yueries are called @seudo5*olumns. ?:curr(alAnet(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.

3. 9P)? =<)? P--?-PT? K89*TI<9= <K =MH Pns: PN-A )PA =8)A = 8)A )I9A*<89T.

4. OGPT I= "IKK??9*? 0?TO??9 *<89T CDA *<89T CD K89*TI<9=H Pns: *ount CD will count the specified s pecified column whereas count CD 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 =8058?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 T8? 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 eecuted once for each E*andidate rowF /y the main YueryA which on eecution 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.

  !4. OGPT P? ]=?T] <@?PT<=H Pns: 89I<9 PMMA89I<9A I9T?=?*T A)I98= are =?T <@?PT<=.

 

42

  !. OGPT I= "IKK??9*? 0?TO??9 0?TO??9 ]89I<9] P9" ]89I<9 PMM] <@?PT<=H Pns: 89I<9 will return the (alues distinctly whereas 89I<9 PMM will return e(en duplicate (alues.

!!. 9P)? =<)? 98)0?A *GPP*T?A "PT?A *<9N?=I<9A <TG? K89*TI<9=. Pns: Nu"9er 1u!ctio!%'  

ound CmA nDA Trunc Trunc CmA nDA @ower CmA nDA =YrtCnDA P/s CmDA *eil CmDA Kloor CmDA )od CmA nD AsignCnD

<haracter 1u!ctio!%' *hr CDA *oncat Cstring1A string2DA Mower CstringD  

8pper CstringDA =u/str CstringA from7strA to7strDA P=*II CstringD

 

Mength CstringDA Initcap CstringD.

Date 1u!ctio!%: =ysdateA )onths /etween Cd1A d2DA To7char To7char CdA formatD  

 

Mast day CdDA 9et7day 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 TP9=MPT? TP9=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 412 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 eists 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 eists 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_ TI--?= *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. 9et(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 Indees 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 eists 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 epensi(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.

%%. 9P)? =<)? =M@M8= *<))P9"=H Pns:

"?=* *I0? *I0?A A =TPT =TPTAA -?TA -?TA =PN?A =PN?A 6 are =M@M8= =M@M8= *<))P9" *<))P9"=. =.

  %'. OGPT P? ]=M@M8= ?@<TI9-] *<))P9"=H Pns: =@<<M file5nameA =@<<M <KKA TTITM?A 0TITM?A 0?P; <9A *<)@8T? Sany aggregate function <K Scolumn name /reak <9 Scolumn name etc are =M@M8= ?@<TI9- *<))P9"=.

'#. OGPT P? =B=T?) P9" <0?*T @INIM?-?=H Pns: *onnect and esource etc are =ystem @ri(ileges. *reate So/ZectA =electA InsertA Plter etc are </Zect @ri(ileges.

  '1. OGPT K< "*M *<))P9"= *<))P9"= P?H Pns: *ommitA oll/ack are "*M commands.

  '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.

  '3. G<O T< *GP9-? @P==O<" <K P 8=?H Pns: 8sing @assword command or 8sing PMT? PMT? 8=? Suser name I"?9TIKI?" 0B Snew password *<)P9".

 

47

'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 IndeesA @ackagesA @roceduresA =eYuencesA =ynonymsA Ta Ta/lesA /lesA "ata/ase TriggersA TriggersA Niews.

  '. G<O T< =TPT8@ =TPT8@ 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 =TPT8@ 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: 12  & P.

  '%. G<O T< )P;? ?N?B ")M <@?PTI<9 P= P8T< *<))ITH Pns: 0y using =?T P8T<*<))IT <9 command.

  ''. G<O T< "I=@MPB "I=@MPB "PTP "PTP @P-? OI=? I9 =MH Pns: 0y using =?T @P8=? <9 command.

1##. G<O T< *GP9-? MI9? =IX?A @P-? =IX? P9" =M @<)@TH Pns: 0y using =?T MI9?=IX? S(alueA =?T @P-?=IX? S(alueA

 

48

 

=?T =M@<)@T Snew prompt.

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#2. OGPT I= P*GIT?*T8? <K @M6=MH Pns:

-i(e picture & ?plain

1#3. OGPT I= P @M6=M 0M<*;H Pns:

"?*MP? Sdeclarations 0?-I9   S?ececuta/le =tatements ?*?@TI<9   S?ception GandlerCsD ?9"W

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 eecuta/le statements are placed. This /lock is )andatory.

 

?*?@TI<9 0M<*;: In this /lock all the eceptions 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 NPIP0M? 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 eecutes the procedural procedural part of the statements and sends the =M statements to the =M statement eecutor in the <racle ser(er. ser(er.

1#'. OGPT I= "?KP8MT "?KP8MT NPM8? K< P 98)?I* @M6=M NPIP0M?H Pns: 98MM

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 eit 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.

114. OGPT P? *8=< *8= < PTTI08T?=H Pns: ^Kound  

^9otKound

 

^Is<pen

 

^ow*ount are the cursor attri/utes.

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. 9P)? =<)? 08IMT5I9 08IMT5I9 ?*?@TI<9=. Pns: Too7)any7owsA Too7)any7owsA 9o7"ata7KoundA  

=torage =torage7?rrorA 7?rrorA

Nalue7?rror Nalue7?rro r etc.

Xero7"i(ideA

9ot7Mogged7<n

 

51

11%. G<O T< *?PT? P 8=?5"?KI9?" ?*?@TI<9H Pns: 8ser5"efined ?ception is created as follows:  

"?*MP? Seception name ?*?@TI<9W 555555555W

 

5 5 5 5 5 5 5 5 5W 0?-I9

 

5 5 5 5 5 5 5 5 5W

 

5 5 5 5 5 5 5 5 5W PI=? Seception nameW ?*?@TI<9 OG?9 Seception name TG?9

 

5 5 5 5 5 5 5 5 5W

 

5 5 5 5 5 5 5 5 5W ?9"W

11'. OGPT I= ]<TG?=] ?*?@TI<9H Pns: It is used to along with w ith one or more eception 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 eception 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@PP)PT?=.

122. OGPT P? "IKK??9T TB@?= <K =805@<-P)=H Pns: TG?B  TO< TB@?=: 1D @<*?"8? 2D K89*I<9.

123. G<O P @<*?"8? I= "IKK??9T K<) P K89*TI<9H Pns: Kunction has return key word and returns a (alue whereas a @rocedure doesnFt return any (alue.

124. OGPT P? TB@?= <K @PP)?T?= TGPT *P9 0? @P==?" T< K89*TI<9 < @<*?"8?H Pns: I9A I9 <8TA <8T.

12. OGPT I= ]I9 <8T] @PP)?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!. "<?= <P*M? =8@@<T= @<*?"8? <N?M<P"I9-H Pns: 9<.

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.

13#. "<?= <P*M? =8@@<T= ?*8=IN? K89*TI<9 *PMM=H Pns: B?=.

131. OGPT I= P TI--?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 eplicitly 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 TI--? P9" P *<9=TPI9TH Pns: *onstraints are always T8? whereas Triggers are 9<T always T8? and *onstraints has some limitations whereas Trigger has no limitations.

133. OGPT P? "IKK??9T ?N?9T= K< P TI--? 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 TI--?=H Pns: Ta/le Ta/le le(el Triggers eecute once for each ta/le /ased transaction whereas ow le(el Triggers will eecute once K< ?P*G <O.

 13. OGPT P? P8T<9<)<8= TI--?=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] TI--?H Pns: These Triggers are used with the *omple Niews only to make possi/le of InsertA 8pdate and "elete on those Niews. Niews .

 13. G<O )P9B TI--?= *P9 * P9 0? *<9KI-8?" <9 P TP0M? P9" NI?OH Pns: 1% Triggers Triggers

13%. OGPT I= ]TP0M? )8TPTI9-] ?<H G<O T< =<MN? ITH Pns:: <P5# Pns <P5#4#' 4#'1: 1:

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?" NPIP0M? I9 @M6=MH Pns: "efine ( (aria/le aria/le in declaration section

142. G<O T< *?PT? P9 PPB NPIP0M? I9 @M6=MH Pns: 8sing *?PT? < ?@MP*? TB@? Stype name P= NPPB Csi+eD <K ?M?)?9T7TB@? C9<T 98MMD *ommandW

143. G<O T< )P;? P 8=?5"?KI9?" "PT "PTP P TB@? -M<0PM I9 @ @M6=MH M6=MH Pns: "eclare the (aria/le in a @ackage

144. G<O T< *?PT? P9 <0?*T I9 <P*M?H Pns: 8sing *?PT? < ?@MP*? TB@? Stype name P= <0?*T CPTTI08T? 9P)? "PTP TB@?A..D *ommand

14. OGPT I= P TP9=I?9T P9" @?=I=T?9T <0?*TH Pns: The </Zect created in a ta/le is called @ersistent </Zect.  

</Zect created on eecution of @M6=M /lock is called Transient Transient </Zect.

14!. OGPT I= P *<M8)9 <0?*T P9" TP0M? <0?*TH Pns: P *olumn </Zect is only a *olumn of a ta/le.

14. G<O T< -P9T @?)I==I<9 <9 P9 <0?*T T< <TG? 8=?H Pns: -P9T Spermission <9 So/Zect name T< Suser name.

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 NPPB P9" 9?=T?" TP0M?H Pns: Narray has a fied si+e.  

9ested ta/les can carry any num/er of (alues.

1#. G<O T< )<"IKB *<9T?9T= <K P NPPB I9 <P*M?H Pns: To modify a stored NPPB it has to selected s elected into a  

@M6=M (aria/le and then inserted /ack into the ta/le.

11. 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.

12. 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.

13. 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?   14. OGPT I= =MH 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 P? "IKK??9T =T?@= T< OIT? P "B9P)I* =M @<-P)H Pns: ?g: char c7sYlstring[`Q"?M?T? K<) sailors OG?? ratingRW ratingRW ??* =M @?@P? readytogo K<) :c7sYlstringW ??* =M ??*8T? readytogoW

1. OGPT I= TP0M? @PTITI<9I9- P9" I9"? @PTITI<9I9-H Pns: <racle% allows ta/les and Indees 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 =T8*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!#. OGPT I= M<-I*PM )?)<B =T8*T8? <K <P*M?H Pns: "ata/aseA Ta/lespace A "0 </ZectA =egmentA ?tents

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 eecute 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  

Ta/lespace Ta/lespace is a Mogical component

1!. OGPT I= <0 <K "PTP0P=? "PTP0P=? OIT? C"0OD @<*?==H

 

59

Pns: The "ata 0ase Oriter writes modified /locks from the data/ase /uffer cache to the data files.

1!%. OGPT I= <0 <K M<- OIT? CM-OD @<*==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.

 11. OGPT I= P =T<?" = T<?" 8?BH Pns: NI?O

12. OGPT I= 8=? @<*?== P9" =?N? @<*?==H Pns: P 8ser process is created and maintained to eecute 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.

13. 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.

14. 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 ;#DA; 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  

from emp cross Zoin deptW

5555555555555555555555555555555555555555555555555555555555555555555555555555 9ew "ate Kunctions:

 

62

 =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 etractCday from sysdateD A  etractCmonth from sysdateDA  etractCyear 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:  *oalesceCepr1Aepr2Aepr3A.......D 555 @icks the first not null epression result .

 

63

nullif C epr1Aepr2 D 555 If epr1 and epr2 results are same it returns 98MM (alue otherwise it return epr1 result.  9(l2Cepr1Aepr2Aepr3D 555 If epr1 is null it manipulates epr3 Aif epr1 is not null it manipulates epr2.

select coalesceC1## > nullA 12% 5 null > 1###A 12  nullA  

22A 234A'%%'D from dualW 55 22

select enameA Zo/A coalesce Ccomm  2A sal  1.D /onus  from empW

select nullifC1##A# 2DA nullifC3##A3#  1##DA   nullif C!##A3## > 3##D from dualW 55 null 3## null

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 eisting 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 .

merge

*lauses:

into Te Temp mp T

into 55 Ta Target rget

using emp ?

8sing 55 =ource

on C T.empno T.empno [ ?.empno D

<n 55 oin condition

when matched then update set t.sal [ e.salA  

t.comm [ e.commA

 

t.deptno [ e.deptnoA

 

t.Zo/ [ e.Zo/A

 

t.mgr [ e.mgr

when not matched then

 

66

insert (aluesCe.empnoAe.en (aluesCe.empnoAe.enameAe.salAe.commA......DW ameAe.salAe.commA......DW

0efore : ?mp 5 1 *rore rows Temp Temp 5 *opy of emp 5 1 *rore *r ore rows Pfter : ?mp 555 ### inserts & 1### 8pdates performed 5555555555555555555555555555555555555555555555555555555555555555555555555555 ename *onstraint & *olumn : Plter ta/le emp rename constraint sys7c##232 to pk7empW Plter ta/le emp rename column ename to emp7nameW 5555555555555555555555555555555555555555555555555555555555555555555555555555 'i =upports : Pd(anced Keatures of PNP Impro(ed internal Prchitecture related to PNP =upports )M.

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close