unix shell-scripting basics complete commands

62
1 MADHAV K UNIX COMMANDS 1. $ LOGNAME : It displays the current user information 2. $PWD : present working directory 3. $DATE : It displays the system date & time 4. $clear : To clear the screen . $cal : it current month and year !. $cal 2000 : "isplays the 2### year calendar . $cal 8 2006 : displays the % th  month of 2##! %. $exit or logout : eit from current user account '. $ who : displays the all user in who are currently working on ser(er 1#. $i!ger : displays the all user who are currently working on ser(er with more information 11. Who a" # : displays current user information 12. Which or where : displays the location of the gi(en command  )yn: $which pwd 13. at : is use to create new files or to open eiting files or to append data to the eiting files reate: cat *filename +++++++++++ +++++++++++cntl,d %e&irect' cat file1 file2 file3 *file4++++++++re&irect out(ut A((e!&: cat **filename++++++++  )i!gle ile $cat file1 file2 file3 **-/++++++"ulti files +++++++++++ +++++++++++cntl,d O(e! ile' cat *ile!a"e+++++  o(e! )i!gle file $cat file10 file20 file3++++++++++to o(e! "ulti files at *.filename+++++++++for hi&&e! files

Upload: siva86

Post on 03-Jun-2018

244 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 1/62

1MADHAV K

UNIX COMMANDS 

1. $ LOGNAME : It displays the current user information

2. $PWD : present working directory

3. $DATE : It displays the system date & time

4. $clear : To clear the screen

. $cal : it current month and year

!. $cal 2000 : "isplays the 2### year calendar

. $cal 8 2006 : displays the %th month of 2##!

%. $exit or logout : eit from current user account

'. $ who : displays the all user in who are currently working on ser(er

1#. $i!ger  : displays the all user who are currently working on ser(er with

more information

11. Who a" #  : displays current user information

12. Which or where  : displays the location of the gi(en command

  )yn: $which pwd

13. at : is use to create new files or to open eiting files or to append

data to the eiting files

reate: cat *filename

+++++++++++

+++++++++++cntl,d

%e&irect' cat file1 file2 file3 *file4++++++++re&irect out(ut

A((e!&: cat **filename++++++++ )i!gle ile  $cat file1 file2 file3 **-/++++++"ulti

files

+++++++++++

+++++++++++cntl,d

O(e! ile' cat *ile!a"e+++++ o(e! )i!gle file $cat file10 file20 file3++++++++++to o(e!

"ulti files

at *.filename+++++++++for hi&&e! files

Page 2: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 2/62

2MADHAV K

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

): $ touch filename

$ touch file1 file2 file3+++++++++ create multiple files

1. r" : deleting files or directories

-5

rm filename++++++++++++++++deleting single file

rm +i filename++++++++++++++deleting files with confirmation

rm file1 file2++++++++++++++++deleting multiple files

rmdir dirname++++++++++++++deleting the directory ut the directory must e empty

rm +r dirname+++++++++++++deleting directory recursi(ely 6i.e. with tree str7

rm 8ri dirname+++++++++++++remo(e directory with confirmation

rm 9 +++++++++++++++++++++ it delets all files

rm +I 9++++++++++++++++++++delets all files with confirmation

rm t9 +++++++++++++++++++++it delets whose file name starts with t; 

1!. ",&ir  : creating directories

)yn: $mkdir dirname

)ys: $kdir .dirname++++++++++++hidden directory

1. & : change directory

)ys: $cd ac

$pwd++++++<home<madha(<ac using ao(e cmd we can come out from ac now we

at <<home<madha(

cd..+++++++++++++++++++++++++++to come out from current directory

cd..<..++++++++++++++++++++++++parent directory

cd<+++++++++++++++++++++++++++it changes to root directory

cd =+++++++++++++++++++++++++it changes to home directory

Page 3: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 3/62

Page 4: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 4/62

4MADHAV K

3#. c"( : it compares two files char y char

)ys: cmp file1 file2

-: a1: Gello Hood orning

  a2: Gello Hood -(ening

  If two lines are same then return nothing

  If two files are are different then it displays line numer with character position

31. co"".  : It display common lines <w 2 files

  )yn: omm Bile1 file2

32. &i  : it display different lines <w 2 files

33. (g : it display the file contents page y page

  )yn: $/g filename

34. "ore : 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 8n filename

3. tail : it display the last n lines from file

  )yn: tail 8n filename

  Tail ,n filename++++it indicates nth line to end of the line

-: tail ,3# file 6in this file total no of records is 1##7 it displays the records from 3# th to

1##

3!. wc : it counts the no of lines0 words0 chars in a gi(en file.

  )yn: $wc filename

i7 wc 8l filename++++++++++++++++++it gi(es the no of lines in a gi(en file

ii7 wc 8w filename+++++++++++++++it gi(es the no of words in a gi(en file

III7 wc 8c filename+++++++++++++++ it gi(es no. of char in file

i(7 wc +lw filename++++++++++++++ it gi(es the no of lines and character in a gi(en file

Page 5: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 5/62

5MADHAV K

3. ID" J?" GJ?T-?) or -TJ GJ?T-?)

i7 9;++++++++it matches #; or more chars

ii7 >; +++++++it matches any single chars

iii7 A F +++it matches any single chars in the gi(en list

i(7 8++++++it matches any single char in the gi(en range

1) ls t9+++++++++++++++it list the files starts with t; 

2) ls 9s +++++++++++++it list the files that ends with ); 

3) ls 9k++++++++++++++it list the files starts with ; and ends with k; 

4) ls a>++++++++++++++it list the 2 characters filename 1st later fallowed y a; and

second letter is any one character

5) lsAkntF+++++++++++it list the files starts with ; or k; or n; or t; 

6) ls AacdefghF or lsAa+hF9++list the files0 first char <w a; to h; 

7) ls A+kFAp+tFAd+nF9+++++++++ it list the files the 1st character ; to k; 2nd char p; to t;

3rd char d; to n; after that any no of characters

3%. gre( : Agloally search a regular epression and print itF

Is used for to search a string or regular epression in a gi(en file6s7

I7 -g: $ grep madha( sample

K<p: 2nd line

th line

Page 6: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 6/62

6MADHAV K

th line

  ii7 -g: $grep madha( a10 a20 a3:

  a1:++++++

  a2:++++++

a3:++++++

  iii7 $ grep techno 9++++++it searches for techno in current dir files 6all files7

  i(7 $grep techno soft sample+++++it searches for more than one word

e kept it in L L

  (7 $grep Ltechno softM sample

gre( c"& o(tio!)

$ grep 8i techno sample+++++++++++++++++++++++ignore case sensiti(e

$ grep 8c techno sample+++++++++++++++++++++++count no of lines

$grep 8n techno sample+++++++++++++++++++++++print along with the line numers

$grep 8l techno 9++++++++++++++++++++++++++++++list only file names

$grep 8( Ltechno softM sample+++++++++++++++not matches print the lines

$grep 8ci techno sample++++++++++++++++++++++Ignore case sensiti(e found no of lines

$grep Ltechno 9M sample+++++++++++++++++++++pattern

%egular ex(re))io!' any string contains wildcard charctor knows as regular epression or

pattern

  These patterns are of  5 t3(e):

harctor (atter!: the default pattern is char pattern only

i7 $grep Ltechno 9M sample

ii7 $grep L AaeiouF llM sample

iii7 $grep L..dM sample+++i.e. or matches any single charctor

Wor& (atter! :<N <*

  <N +++++++start of the word

 <*++++++end of the word

Page 7: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 7/62

7MADHAV K

Hrep L<Ntechno<*M sample ++++++++++++o<p: techno

Hrep L<NtechnoM sample++++++++++++++++o<p: techno soft

  +++++++++++++++++o<p: techno 123

Hrep Ltechno<*M sample ++++o<p: hellotechno0 actechno

Hrep L<N A#+'FA#+'FA#+'FA#+'F<*M sample++++++++++++++it display 4 digits

6i.e.12340 4!7

Li!e (atter!' ++++++++++starts of the file

  $++++++++++ends of the file

-: grep LOdM sample+++++++++++++++it display the line starts withd; 

  Hrep LOtheM sample+++++++++++++++++it list the lines start with the; 

  Hrep LO<Nthe<*M simple ++++++++++sample the line eactly start with the; 

  Hrep Lt$M simple+++++++++++++++++++list the line ends witht; or last char ist; 

  Hrep LA#+'F $M sample++++++++++++ display the line ends with # to ' digit

Hrep LO AktFM sample++++++++++++list the line starting with ; or k or;t; 

Hrep LO AOktFM sample++++++++++list the line which is not start with ; or k; ort; 

Hrep LMOPI5$M sample +++++++++display the line ha(ing only word Pni; 

Hrep LOQ. $M++++++++++++++++++++++list the line which contains 4; characters

6.7++++++++++++++++++++++++++++++++++represent single charctor

Hrep LO.M++++++++++++++++++++++++)ample it list all lines

Hrep L<.M )ample: ++++++++++++++it lists the line start with 6.7

e use R to search 90 $0 O as a charctor+++++++ i.e.R90SO0R$

Hrep LO$M sample++++++++++++++ it list empty lines

Hrep 8c LO$M sample++++++++++counts no of empty lines in a file

Hrep 8( LO$M sample++++++++++print not matches 6i.e. not empty7 lines

Hrep 8( LO$Msample *temp

( temp sample+++++++++++++++++++here oth are delete empty files

Page 8: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 8/62

8MADHAV K

3'. gre( : it is used for search multiple strings ut it doesn;t allow to search regular

epression

  $grep Lhello

  *techno

  *PI5Msample++++++++++it searches for hello or techno str PI5

4#. egre(  : it is comination of grep and fgrep

  $egrep Lhello

  *hello

*PI5Msample $egrep LO$M sample

41. 7e& : to replace a string

$ sed Ls<eisting string<new string<gM filename++sed is used to find and replace and grep

is for find print

i7 $sed Ls<Pni<Dinu<gi Lmadha(: +++++++++++++ i for case sensiti(e

ii7 $sed Ls<OPni<Dinu<giM++++++++++++++++++++++ whate(er lines starting with PI5 are

replaced y Dinu

iii7 $sed Ls<O$<I like Pni<g IM sample++++++++empty string are filled with I like PI5;; 

i(7 $)ed Ls<Pni<<g IM sample+++++++++++++++++it search PI5 if found replace with nothing;

6empty7

42. tr : to translate a charctor

i7 tr LaM LpM Ns++++++++++++++++++++ it read data from sample and a; is replaced y p; 

ii7 tr LaeiouM LJ-IKPMNsample++++replace char y char

iii7 tr L0M LltM Nemp++++++++++++++++whene(er L0M is there replace with ta space

  i(7 tr LAa+@FM LAJ+F N)i(a++++++++ con(erts hole file into uppercase

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

-: madha( is good oy++1% chars

ut 8f 2+ madha(+++o<p: adha

ut 8c 1+1# madha(

ut 8c +1#0 1+2# madha(+++++++for e(ery line +1#0 1+2# characters

447 Pa)te : is used for to Voin two or more files hori@ontally y using delimiter

Page 9: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 9/62

9MADHAV K

at *states cat *cities paste 8d L:Mstates cities*tr

filename

J/ Gyderaad J/: Gyderaad

Tamilnadu madras Tamilnadu: madras

Warnataka Xangalore Warnataka: Xangalore

Werala Tri(andrum

aharashtra Xomay

47 7ort : it is used for to sort the file content. Xy default it sorts file contents ased

on J)II (alues+default is ascending

)ort sample

i7 sort 8r sample++++++displays descending order

ii7 sort 8u sample+++++it displays uniUue lines in the gi(en file

iii7 sort 8n file++++;M numeric comparisons

i(7 sort 8nur file

(7 sort sample *temp

$m( temp sample

7orti!g the &ata iel& 3 iel&

,pos++starting field

+/os++ending field 6optional7

i7 )ort 8f ,pas1 8pas2 filename

ii7 )ort 8f ,1 +3 filename+++++starting from end efore 3

iii7 )ort 8fn ,2 +3 file ++++++it gi(es only numers

4!7 9!i: : it displays uniUue lines in the gi(en file ut the file contents should e in

sort order

-:file1 i7 $ uniU file ii7 $uniU 8u filename++it eliminates duplicates

Jaaaaa

Jaaaaa Jaaaaa ccccc

Jaaaaa cccccccc ddddd

cccccc dddddd /pppp

Page 10: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 10/62

10MADHAV K

"dddd hhhhhh ttttttt

Ghhhh pppppp

Ghhhh ttttttttt

/pppp

Ttttttt

iii7 $ PniU 8d filename++++displays only duplicated lines IE7 uniU 8c filename+++++it counts

how many times lines duplicated

  Jaaaaa+++++2

  ccccccc++++1

E7 $ uniU 8u file *temp

$ m( temp filename

"elete duplicated lines from file "dddd+++++1

Ghhhhh+++2

/pppp+++++1

Ttttttt+++++1

47(i(i!g;  : it is used for to comine 2 or more cmds Stake left side o<p to right

side cmd as i<p

i7 $who Swc 8l+++++++++count total no of lines 6files7 in current directory

ii7 $ lsSwc 8l++++++++++++displays total no of sudirectories in the current directory

iii7 ls 8l Sgrep LOdM++++displays total no of sudirectories who stats with line nod; 

iE7 $head +3# sampleStail ,2# sample++++++display the the lines from 2# to 3# from

gi(en file

(7 $ grep PI5 stud S cut 8f 20 3Ssort filename +++++display PI5 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 PI5 stud S cut 8f 20 3 Ssort Stee file1

<= 7hell )cri(ti!g'

It is group of PI5 commands and shell keywords

Page 11: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 11/62

11MADHAV K

The main concept of shell scripting is to handle tet files

I7 >ou!e )hell++++stea(e Xourne +++++$++++++++sh+++ 6sh as i!ter(reter

ii >a)h )hell 6orne again shell7 +++same as ao(e++ad(anced (ersion of Xourne is

XJ)G 6Dinu default shell7

iii ?or! )hell++++++"a(id korn++++$++++++++++ksh 6interpreter7 ++++used as JI5 default

shell

ostly used shell is korn shell it supports re usaility0 all shell designed on ourn shell

# $,)h : shift to korn shell

@17 $echo $0   : it displays current child shell name

@2 $alia)  : it lists all alias names

@5 9!alia) alia) !a"e)' to delete alias names

@< $ hi)tor3   : it displays the pre(iously eecuted commands

@@ Echo : it display the string on screen 6monitor7

ile (er"i))io!)';xxxxxxxxx

9)erow!er+++(er"i))io!) ;ir)t (art

Grou( (er"i))io!) ;)eco!& (art

Other (er"i))io!) ;thir& (art

B+++ ;a&& (er"i))io!) to ugo ut it &oe) !ot &elete exiti!g (er"i))io!

+++ ;&e!3 (er"i))io!)

C++++ ;a))ig! (er"i))io!) ;a&& (er"i))io!) to ugo ut it &elete exiti!g

(er"i))io!

rw+<rw+<r++ +++++++++"efault permissions for regular files

rw<rw<r++++++++++default permission for directories

!7 ch"o& : it is used for to change file permissions

)yn: $chmod who< A,<+<YF<

i7 ls 8l filename+++++++rw+ rw+ rC

ii7 chmod g, filename+++++rw+ rw rC

iii7 chmod u,0 g+w filename++++++rw r+ rC

Page 12: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 12/62

12MADHAV K

iE7 chmod gYw filename+++++rw 8w+ rC

Octal co&e

%ea&++++++<

Write+++++2

Execute1

$chmod ! filename+++++++rw r+ rw+

$chmod !42 filename++++rw+ r++ +w+

7 chow!   : to change owner name of the file

Zchown owner name filename

% chgre(  : to change group name of the file

Z chgrp group name filename

% $write  : it is user for to with the users ut the user should e logged into the ser(er

$write techno2 ii7 $mesg n++deny the msg

Gello iii7 mesg y+to allow msges

mtl,d

'7 aw,!aw, file : scan for patterns in a file and process the results

!# cat  : concatenate 6list7 or file

!17 ch)h 6paawd 8e<+s7 userlogin[shell: change the user login shell

!27 &  : report the summary of disk locks and nodes free and in use

  i7 df 8k+++it displays the disk space in ytes

  ii7 df 8h+++it displays disk space in kilo ytes

  iii7 df 8g+++it displays the disk space in giga ytes

!37&u  :it displays the directory wise disk usage in form of locks each lock si@e is 12ytes

!47g i(  :to create a @ip file

- $g@ip filename++++o<p: filename.g@

!7 gu!i(   : to un@ip the files

Page 13: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 13/62

13MADHAV K

-: gun@ip filename.g@

!!. co"(re)) : it also used for to @ip the file+++it used to sa(e with .@ format

!7 9!co"(re)) : same as ao(e

H@ip sa(es more memory than compress

!%7 cat  : it used to displays @ip file contents in readale format

$@cat sample.g@

Kr

$@cat sample.@

!'7 To ,ill oregrou!& Fo c!tlBc or c!tlB

$ sleep ##

ntl,c

$ sleep 1##& 

#7 () or $ () /   : it displays current user account running process list 6show status of

acti(e process7

17 $() /a: it displays all user accounts running process list

27 ?ill   : it kill ackground process

-: kill /I"

37 tel!et : to connect to remote ser(er

47 t(: file transfer protocol +++++transfer files from one ser(er to another

  $ ftp ipaddress

Dogin: +++++++

/assword: ++++++

Btp*ls 6ser(er7

Btp*Sls6client7

Btp*get filename 6to download a file7

Btp*mget file1 file2+++++ 6to download multi files7

Page 14: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 14/62

14MADHAV K

Btp*put filename 6to upload a file7

Btp*mput file1 file2+++++ 6to upload multi files7

7t(: to transfer files from one ser(er user account to another ser(er user account

  $su root ++to switch to admin

!7 Wall  : it is used for to sent roadcast message to all users who are

currently working on ser(er

$wall

Gappy new+year

ntl,d

7"ail  :it is used for to send the mail0 if user is not logged in then also we can send

mail

i7 $ mail techno1

ntl,d e(ery user contains mailo

at a time we can send msg to multiple users

27 $mail techno1 techno2 techno 3

)u: from techno

ntl,d

iii7 $ mail technoNstud

stud send content as a mail to techno3

mail is the cmd to read mails in the mailo

$mail

1*first mail

2*second mail reading

&2 it Uuickly opens second mail

&U++Uuit from mail o

&w to sa(e mail contents to a file

&pprint mail contents

&r++replays

Page 15: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 15/62

15MADHAV K

&d+delete mails

%$"ail / :to read mails send to secondary mailo

'7 e"ac) :full screen editor

%# echo : echo the tet string to on monitor

%17 ile  : classify the file type

%27 ex(r : e(aluates the arguments0 used to do arithmetic0etc in the shell

%37 i!& : find files0 matching a type or pattern

%47 o)t!a"e  : display or set the name of the current machine

%7l! : link the source to target

%!7l(:0l()tat :show the status of the print Vos

%7l(rHl(  :print to defind printer

%%7 l(r"H ca!cel : remo(e a print Vo from the print Uuee

%'7 "a! :display manual of gi(en cmd

=0o& :octal dump a inary file0in octal0J)II0he0decimal or char

'17(a))w& :to set or change password

'27 (r : filter the file and print it on the terminal

'37 rc( ho)t!a"e : remotely copy files from this machine to another machine

'47 rlogi!e ho)t!a"e: login remotely to another machine

'7 r)h ho)t!a"e : remote shell to run on another machine

'!7 )cri(t ile : sa(es e(erything that appears on the screen to file until eit is

eecuted

'7 )ource ile : read cmds from the file and eecute them in the current shell

'%7 )tri!g ile : used to search inary files for J)II strings

''7 7t3 : set or display terminal control options

1##7 uu&eco&e ile : decode a uuencoded file0 recreating the original file

1#17 uue!co&e !ew !a"e : encode the inary file to +it J)II0usefull when

sending (ia email0 to e "ecode as new name at destination

1#27 -i : (isual 0full screen editor

Page 16: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 16/62

16MADHAV K

1#37 Fo) : display ackground and suspended processes

1#4 ,ill I1 : remo(e suspended process Z1

1#7 to(  : display the current0 most computer+intensi(e commands

1#!7 o)-iew : display the operating system statistics

1#7 )ete!- : list en(ironmental (ariales

9N#J

What i) "ea!t 3 (a))w& ileK

This file maintains each and e(ery user information with fields. The fields are Psername:

passwd: uid: gid: fullname: home: shell.

What i) 7hellK

)hell is a command line interpreter. )hell acts as an interface etween user and the kernel.

What i) ?er!elK

Wernel is core part of PI5 o<s. It is a group of hundreds of system calls.

What are &iere!t la-or) o 9!ix o)K

Jny operating system designed ased on uni kernel called as fla(our of uni. The following

are some fla(ours of uni

Dinu ++++ ?ed Gat

)un solaris +++ )un icrosystem

IX+JI5 +++++ IX

Gp+u +++++ G/

)co+uni +++++ santa crus operations

I?I5++++++ )ilicon Hraphics.

What are the &iere!t )ecurit3 eature) i! 9!ixK

  1. /assword protection.

2. Bile permissions.

Page 17: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 17/62

Page 18: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 18/62

18MADHAV K

Ds 8a

ow to )ee ile) a!& )u&irectorie) ile) recur)i-el3K

Ds 8?

ow to )ee ile) i! lo!g li)t or"at (age wi)eK

Ds 8l S more

ow to i&e!ti3 whether a ile i) !or"al ile or &irector3K 

$ls +l filename<directoryname

if the first digit is + then it is file0

if it is d then it is directory file

What i) the &iere!ce etwee! l) +r a!& l) +%K

 ls +r lists the files in re(erse alphaetical order... whereas ls +? lists the files and directories

recursi(ely

The &iere!ce etwee! a )ot li!, a!& a har& li!,K

J symolic 6soft7 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)K1.touch + to create empty files 6e.g7 + touch Nfilename*

2.(i Nfilename*

3. cat*filename

Li)t )o"e wil& car& character)K

> + Iit matches any single character

9 + It matches @ero or more characters

AF + It matches any single character in gi(en list

. +  It matches any single character ecept enter key character

what i) the out(ut o the ollwi!g co""a!& ' l) a+"!o+r4

list all the files in the current directory starting alphaet

Page 19: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 19/62

19MADHAV K

is etween a to m or n or etween o to r

ow &o 3ou cou!t wor&)H li!e) a!& character) i! a ileK

c Nfilename*

which co""a!& i) u)e& to i&e!ti3 the t3(e o the ileK

file

gre( "ea!)

Hloally search a regular epression and print it

ow &o 3ou )earch or a )tri!g i!)i&e a gi-e! ileK

grep string filename

ow &o 3ou )earch or a )tri!g i!)i&e a curre!t &irector3K

grep string 9

ow &o 3ou )earch or a )tri!g i! a &irector3 with the )u&irectorie) recur)e&K

 grep +r string 9

Diere!ce etwee! gre(H egre( a!& gre(

grep : does not accept more then one epression

egrep : accepts more than one pattern for search. Jlso 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!)K

O + start of the line

$ + -nd of the line

ow to )earch e"(t3 li!e) i! a gi-e! ileK

Hrep LO$M Nfilename*

Page 20: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 20/62

20MADHAV K

ow to cou!t !o o la!, li!e) i! a ileK

Hrep 8c LO$M Nfilename*

ow to re"o-e E"(t3 li!e) or" a gi-e! ileK

Hrep 8( LO$M filename * temfilename

( tempfilename filename

What i) (atter! to )earch < &igit wor& i! a ileK

Hrep LRNA#+'F A#+'F A#+'F A#+'FR*M filename

What i) (atter! to )earch the li!e ha-i!g o!l3 three character)K

Hrep LO$Q filename

What i) (atter! to &i)(la3 li!e) e!&i!g with R$Q character i! a gi-e! ileK

Hrep LR$$M filename

ow to &i)(la3 2 a!& < th ile&) ro" a gi-e! ile i the &eli"etr i) R'QK

ut 8dM:M 8f 204 filename

ow to &i)(la3 u!i:ue li!e) ro" a gi-e! ileK

)ort 8u filename

ow to eli"i!ate co"(letel3 &u(licate li!e) ro" a gi-e! ileK

PniU 8u filename

ow to re"o-e all &u(licate li!e) ro" a ileK

PniU 8u filename * tempfilename

( tempfilename filename

ow to &elete RhelloQ wor& ro" a gi-e! ileK

)ed Ls<hello<<M filename

awk  o""a!&

awk  is a powful Pni command. It allows the user to manipulate files that are structured as

columns of data and

Knce you understand the asics of awk  you will find that it is surprisingly useful. ou can

use it to automate things in ways you ha(e ne(er thought aout. It can e used for data

processing and for automating the application of Pni commands. It also has many

spreadsheet+type functionalities.

Page 21: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 21/62

21MADHAV K

There are two ways to run awk . J simple awk  command can e run from the command line.

ore comple tasks should e written as awk  programs 6\scripts\7 to a file. -amples of

each are pro(ided elow.

Exa"(le' ] awk  ^pattern _action`^ input+file * output+file

meaning: take each line of the input file if the line contains the pattern apply the action tothe line and write the resulting line to the output+file.

If the pattern is omitted0 the action is applied to all lines:

ow to co"(are two ile) are )a"e or !otK

mp

ow to &i)(la3 the ir)t 10 li!e) ro" a ileK

Gead +1# filenameWrite a o!e li!e co""a!& to co!-ert all the ca(ital letter) o a ile te)t i!to

lower ca)eK

cat filename S tr \AJ+F\ \Aa+@F\

The (i(eli!e to li)t the i-e large)t ile) i! the curre!t &irector3 i)

 ls +l S tr +s ^ ^ S sort +t ^ ^ +fnr ,4 + S head 8

The (i(eli!e to i!& out the !u"er o ti"e) the character K occur) i! the ile i)

tr +dc ^>^ N file S wc +c 6 "elete all the characters ecept > and then make a word count.7

ow to cou!t total !o. o u)er) wor,i!g i! the )3)te"K

ho S wc 8l

ow to &i)(la3 the li!e) ro" @ to 10 ro" a gi-e! ileK

Gead +1# filename S tail ,

what will e out(ut o ollowi!g co""a!&K

Page 22: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 22/62

22MADHAV K

echo RTec!o)otQ wc /c

'

What i) the &eault u"a),K

#22

What i) the &eault (er"i))io! or ile S Director3 K

The "efault pri(ileges for file : !44

The default pri(ileges for directory :

What 9N#J co""a!& will co!trol the &eault ile (er"i))io!) whe! ile) are

create&K

Pmask

Ex(lai! the rea&H writeH a!& execute (er"i))io!) o! a 9N#J &irector3.

?ead allows you to see and list the directory contents.

rite allows you to create0 edit and delete files and sudirectories in the directory.

-ecute gi(es you the pre(ious read<write permissions plus allows you to change into the

directory and eecute programs or shells from the directory.

What i) ch"o&H chow! a!& chgr(K

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 ileH ut hi)her grou( ha)H ca!he)he e&it itK o. Ge<she can^t0ecause the owner^s permission o(errides the group^s.

To )ee li)t o ile) a!& &irectorie) Hwhat (er"i))io! re:uire&K

?ead permission

What are P#D)K

They are process I"s gi(en to processes. J /I" can (ary from # to !3.

ow &o 3ou li)t curre!tl3 ru!!i!g (roce))K

ps

Page 23: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 23/62

23MADHAV K

ow &o 3ou )to( a ac,grou!& (roce))K

kill pid

ow &o 3ou i!& out aout all ru!!i!g (roce))e)K

() +ag

ow &o 3ou )to( all the (roce))e)H exce(t the )hell wi!&owK

kill #

ow &o 3ou ire a (roce)) i! the ac,grou!&K

 .(roce))+!a"e S 

What &oe) the co""a!& ,ill += $ &oK

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)e&K

ohup

 which co""a!& will get execute& e-e! ater 3ou log outK

 ohup

which )ig!al ca!!ot e tra((e&K

kill 8'

ow to re&irect )ta!&ar& error to a ileK A!)wer

2* filename

What &oe) the to( co""a!& &i)(la3K

top command displays the current ammount of memory occupiedy 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!K

all

Page 24: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 24/62

24MADHAV K

What i) the co""a!& to )e!& "ail to other u)erK

ail username

ow to o(e! )eco!&ar3 "ail oxK

ail +f 

What &o 3ou &o i 3ou &o!Ut wa!t to e i!terru(te& 3 other u)er)U "e))age)K

Jns. mesg n

7hell 7cri(ti!g #!ter-iew :ue)tio!)

Diere!ce etwee! the out(ut o echo a!& echo

echo 99 lists all the filenames in the current directory..

echo 9 9 lists all the filenames in the current directory twice.

The other wa3 o ru!!i!g )hell )cri(t a(art ro" u)i!g )h co""a!& a!& ch"o&K

ans:+ using b we can run a shell script

1'. Gow do you refer to the arguments passed to a shell script> + $1H $2 a!& )o o!. $0 i)3our )cri(t !a"e.

2#. hat;s the conditional statement in shell scripting> + i Vco!&itio! the! i

21. Gow do you do numer comparison in shell scripts> + +e:H +!eH +ltH +leH +gtH +ge

22. Gow do you test for file properties in shell scripts> + +) ile!a"e tell) 3ou i the ile i)

!ot e"(t3H + ile!a"e tell) 3ou whether the argu"e!t i) a ileH a!& !ot a

&irector3H +& ile!a"e te)t) i the argu"e!t i) a &irector3H a!& !ot a ileH +w

ile!a"e te)t) or writeailit3H +r ile!a"e te)t) or rea&ailit3H +x ile!a"e te)t)

or executailit3

23. Gow do you do Xoolean logic operators in shell scripting> +  te)t) or logical !otH +a

te)t) or logical a!&H a!& +o te)t) or logical or.

24. Gow do you find out the numer of arguments passed to the shell script> + $X2. hat;s a way to do multile(el if+else;s in shell scripting> + i Vco!&itio! the!

V)tate"e!t eli Vco!&itio! V)tate"e!t i

2!. Gow do you write a for loop in shell> + or V-ariale !a"e i! Vli)t &o

V)tate"e!t &o!e

2. Gow do you write a while loop in shell> + while Vco!&itio! &o V)tate"e!t &o!e

2%. Gow does a case statement look in shell scripts> + ca)e V-ariale i! V(o))ile+

-alue+1 V)tate"e!tYY V(o))ile+-alue+2 V)tate"e!tYY e)ac

Page 25: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 25/62

25MADHAV K

2'. Gow do you read keyoard input in shell scripts> +  rea& V-ariale+!a"e

3#. Gow do you define a function in a shell script> + u!ctio!+!a"e; V X)o"e co&e here

retur!

31. Gow does getopts command work> + The parameters to your script can e passed as +n

1 + 2#. Inside the script0 you can iterate through the getopts array as while getopts n:

option0 and the (ariale $option contains the (alue of the entered option.

Xatch file:

Xatch files allow )+"K) and icrosoft indows users to create a lists of commands to runin seUuence once the atch file has een eecuted. Bor eample0 a atch file could e used

to run freUuently run commands0 deleting a series of files0 mo(ing files0 etc. J simple atchfile does not reUuire any special programming skills and can e done y users who ha(e a

asic understanding of )+"K) commands.

O%ALE=i  AZ)

1. GJT I) "JTJ K? IBK?JTIK>

Jns: The atter that we feed into the omputer is called "ata or Information.

2. GJT I) "JTJXJ)->

Jns: The ollection of Interrelated "ata is called "ata Xase.

3. GJT I) J "JTJXJ)- JJH--T ))T- 6"X)7 /JWJH->

Jns: The ollection of Interrelated "ata and some /rograms to access

the "ata is alled "ata Xase anagement )ystem 6"X)7.

4. G- J - )J J "X) /JWJH- J) ?"X)>

Jns: Bor a system to ualify as ?-DJTIKJD "JTJXJ)- JJH--T system0

it must use its ?-DJTIKJD facilities to JJH- the "JTJXJ)-.

Page 26: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 26/62

26MADHAV K

. GJT I) K?"X)>

Jns: KVect 6oriented7 ?elational "ata Xase anagement )ystem is one

that can store data0 the relationship of the data0 and the eha(ior of the data

6i.e.0 the way it interacts with other data7.

!. J- )K- K""^) ?PD-).

Jns: "r. -.B. odd presented 12 rules that a dataase must oey if it

is to e considered truly relational. Kut those0 some are as follows

a7 The rules stem from a single rule+ the @ero rule;: Bor a system to ualify as

?-DJTIKJD "JTJXJ)- JJH--T system0 it must use its ?-DJTIKJD facilities

to JJH- the "JTJXJ)-.

7 Information ?ule: Taular ?epresentation of Information.

c7 Huaranteed Jccess ?ule: PniUueness of tuples for guaranteed accessiility.

d7 issing Information ?ule: )ystematic representation of missing information as PDD

Ealues.

e7 omprehensi(e "ata )u+Danguage ?ule: D to support "ata definition0

Eiew definition0 "ata manipulation0 Integrity0 Juthori@ation and )ecurity.

. GJT J?- GI-?J?GIJD0 -TK?W0 J" ?-DJTIKJD "JTJXJ)- K"-D)>

Jns: a7 ierarchical Mo&el' The Gierarchical odel was introduced in

the Information anagement )ystem 6I)7 de(eloped y IX in 1'!%. In this data is

organi@ed as a tree structure. -ach tree is made of nodes and ranches.

The nodes of the tree represent the record types and it is a collection

of data attriutes entity at that point. The topmost node in the structure is called the root.

odes succeeding lower le(els are called children.

7 Networ, Mo&el' The etwork odel0 also called as the K")D dataase

structure0 is an impro(ement o(er the Gierarchical mode0 in this model concept of parent

and child is epanded to ha(e multiple parent+child relationships0 i.e. any child can e

suordinate to many different parents 6or nodes7. "ata is represented y

Page 27: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 27/62

27MADHAV K

collection of records0 and relationships among data are represented y

links. J link is an association etween precisely two records. any+to+many relationships

can eists etween the parent and child.

c7 %elatio!al Mo&el' The ?elational "ataase odel eliminates the need

for eplicit parent+child relationships. In ?"X)0 data is organi@ed in two+dimensional tales

consisting of relational0 i.e. no pointers are maintained etween tales.

%. GJT I) "JTJ K"-DIH>

Jns: "ata odeling descries relationship etween the data oVects. The

relationships etween the collections of data in a system may e graphically represented

using data modeling.

'. "-BI- -TIT0 JTT?IXPT- J" ?-DJTIK)GI/.

Jns: -ntity: Jn -ntity is a thing0 which can e easily identified. Jn entity is any oVect0

place0 person0 concept or acti(ity aout which an enterprise records data.

Jttriute: Jn attriute is the property of a gi(en entity.

?elationship: ?elationship is an association among entities.

1#. GJT I) -?+K"-DIH>

Jns: The -+? modeling techniUue is the Top "own Jpproach. -ntity

relationship is techniUue for analysis and logical modeling of a system;s data reUuirements.

It is the most widely used and has gained acceptance as the ideal dataase design. It uses

three asic units: entities0 their attriutes and the relationship that eists etween

 the entities. It uses a graphical notation for representing these.

11. GJT I) K?JDIJTIK>

Jns: ormali@ation is a step+y+step decomposition of comple records

Page 28: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 28/62

Page 29: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 29/62

29MADHAV K

1!. GJT I) "IBB-?-- X-T-- J /?K-"P?JD DJHPJH- J" J

K+/?K-"P?JD DJHPJH->

Jns:

/rocedural Danguage K+/rocedural Danguage

J program in this implements a step+y+step algorithm to sol(e the

prolem. It contains what to do ut not how to do .

1.GJT T/- KB DJHPJH- \)D\ I)>

Jns: )D is a on+procedural0 4th generation Danguage0< which concerts

what to do rather than how to do any process.

1%. DJ))IBIJTIK KB )D KJ")>

Jns:

""D 6"ata "efinition Danguage7 "D A"ata uerying Dnaguage F

"D 6"ata anipulating Danguage7 "D 6"ata ontrol Danguage7

TD6"ata Transaction Danguage7

reate Jlter "rop Truncate ?ename0 )elect 0 Insert Ppdate "elete erge 0 Hrant ?e(oke 0

?ollack ommit sa(epoint

 

1'. GJT I) "IBB-?-- X-T-- ""D J" "D KJ")>

Jns: Bor ""D commands autocommit is K implicitly whereas Bor "D

commands autocommit is to e turned K eplicitly.

Page 30: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 30/62

30MADHAV K

2#. GJT I) "IBB-?-- X-T-- J T?J)JTIK J" J P-?>

Jns: J Transaction is unit of some commands where as uery is a single

line reUuest for the information from the dataase.

21. GJT I) "IBB-?-- X-T-- T?PJT- J" "-D-T- KJ")>

Jns: Truncate ommand will delete all the records where as "elete

ommand will delete specified or all the records depending only on the condition gi(en.

22. GJT I) "IBB-?-- X-T-- P/"JT- J" JDT-? KJ")>

Jns: Jlter command is used to modify the dataase oVects where as the

Ppdate command is used to modify the (alues of a data ase oVects.

23. GJT J?- KJ") KB "D JT-HK?>

Jns: Hrant and ?e(oke are the two commands elong to the "D ategory.

 

24. GIG I) J -BBII-T KJ" + T?PJT- K? "-D-T-> G>

Jns: "elete is the efficient command ecause using this command we can

delete only those records that are not really reUuired.

2. GJT J?- ?PD-) BK? JIH J TJXD- K? KDP>

Jns: 17 ames must e from 1 to 3# ytes long.

27 ames cannot contain Uuotation marks.

37 ames are not case sensiti(e.

47 J name must egin with an alphaetic character from your dataase

character set and the characters $ and Z.

 Xut these characters are discouraged.

7 J name cannot e K?JD- reser(ed word.

Page 31: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 31/62

31MADHAV K

!7 J name must e uniUue across its namespace. KVects in the name

space must ha(e different names.

7 J name can e enclosed in doule Uuotes.

2!. GK J KDP) J J TJXD- GJE->

Jns: J Tale can ha(e 1### columns.

2. GJT J?- "IBB-?-T "JTJT/-) )P//K?T-" X )D>

Jns: har 6si@e70 char 6si@e70 Earchar2 6si@e70 (archar2 6si@e7 data

types for character (alues0

umer 6precision0 scale70 umer0 umer 6n70 Bloat0 Bloat 6inary precision7 data types

for numerical (alues0 "ate data type for date (alues0

Dong0 ?aw 6si@e70 Dong ?aw0 lo0 Xlo0 clo0 Xfile for large oVects.

2%. GJT I) "IBB-?-- X-T-- DKH J" DKX "JTJT/-)>

Jns:

DKX DKH

17 The maimum si@e is 4HX.

27 DKXs 6ecept DKX7 can e attriutes of an oVect type.

37 DKXs support random access to data.

47 ultiple DKX columns per tale or DKX attriutes in an oVect type.

17 The maimum si@e is 2HX. 27 DKHs cannot. 37 DKHs support only

seUuential access.

47 Knly one DKH column was allowed in a tale

Page 32: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 32/62

32MADHAV K

2'. GJT I) "IBB-?-- X-T-- GJ? J" EJ?GJ?2 "JTJT/-)>

Jns: Earchar2 is similar to har ut can store (ariale no. Kf

characters and while Uuerying the tale (archar2 trims the etra spaces from the column

and fetches the rows that eactly match the criteria.

3#. GK PG -K? I) JDDKJT-" BK? "JT- "JTJT/-> GJT I) "-BJPDT

"JT- BK?JT I K?JD->

Jns: Bor "ate data type oracle allocates ytes emory.

"efault "ate Bormat is: ""+K+.

31. GJT I) ?JH- BK? -JG "JTJT/- KB )D>

Jns:

"atatype ?ange

har Earchar2 umer Bloat DKH0 ?J0 DKH?J Darge KVects

6DKX;s7 2### ytes 4### ytes

/recision 1 to 3% )cale +%4 to 12 /recision 3% decimals Kr 122 inary

precision 2 HX 4HX

32. GK TK ?-J- J KDP>

Jns: e can;t rename a olumn of a tale directly. )o we follow the

following steps.

To ?ename a olumn:

a7 Jlter the tale specifying new column name to e gi(en and data type.

7 Then copy the (alues in the column to e renamed into new column.

Page 33: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 33/62

33MADHAV K

c7 drop the old column.

33. GK TK "-?-J)- )I- K? GJH- "JTJT/- KB J KDP>

Jns: To "ecrease the si@e of a "ata type of a column

i. Truncate the tale first.

ii. Jlter the tale column whose si@e is to e decreased using the same

name and data type ut new si@e.

34. GJT I) J K)T?JIT> GJT J?- IT) EJ?IKP) D-E-D)>

Jns: onstraint: onstraints are representators of the column to

enforce data entity and consistency.There r two le(els

17olumn+le(el constraints 27Tale+le(el constraints.

 

3. DI)T KPT JDD TG- K)T?JIT) )P//K?T-" X )D.

Jns: ot ull0 PniUue0 heck0 /rimary Wey and Boreign Wey or ?eferential Integrity.

3!. GJT I) "IBB-?-- X-T-- PIP-,KT PDD J" /?IJ? W->

Jns: PniUue and ot ull is a comination of two onstraints that can e present any

numer of times in a tale and can;t e a referential key to any column of an another tale

where as /rimary Wey is single onstraint that can e only once for tale and can e a

referential key to a column of another tale ecoming a referential integrity.

3. GJT I) J K/K)IT- /?IJ? W->

Jns: J /rimary key created on comination of columns is called omposite /rimary Wey.

3%. GJT I) J J"I"JT- KDP> GK J J"I"JT- KDP) J X-

/K))IXD- /-? K/K)IT- /?IJ? W->

Jns: It is a part of composite primary key. aimum 32 candidate key can e there in

composite primary key.

Page 34: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 34/62

34MADHAV K

 

3'. GK TK "-BI- J PDD EJDP->

Jns: J PDD (alue is something which is una(ailale0 it is neither @ero

nor a space and any mathematical calculation with PDD is always PDD.

4#. GJT I) PDD> J K)T?JIT K? "-BJPDT EJDP->

Jns: It is a default (alue.

41. GJT I) "-BJPDT EJDP- BK? -E-? KDP KB J TJXD->

Jns: PDD.

42. GJT I) ?-JT-" I/DIITD BK? -E-? PIP- J" /?IJ? W-

KDP)>

Jns: Inde.

43. GJT J?- DIITJTIK) KB G-W K)T?JIT>

Jns: In this we can^t specify /seudo olumns like sysdate etc.

44. GJT I) "IBB-?-- X-T-- ?-B-?--) J" BK?-IH W- K)T?JIT>

Jns: ?eferences is used as column le(el key word where as foreign key

is used as tale le(el constraint.

4. GJT I) \K "-D-T- J)J"-\>

Page 35: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 35/62

Page 36: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 36/62

36MADHAV K

3. J- )K- JHH?-HJT- BPTIK) KB )D>

Jns: JEH0 J50 )P0 I0KPT.

4. GJT I) "IBB-?-- X-T-- KPT 670 KPT 697 BPTIK)>

Jns: ount 67 will count the specified column whereas count 697 will

count total no. of rows in a tale.

. GJT BK? ?KDDP/ J" PX- K/-?JTK?) J?->

Jns: To get sutotals and grand total of (alues of a column.

!. GJT I) J )PX+P-?>

Jns: J Uuery within a Uuery is called a su Uuery where the result of

inner Uuery will e used y the outer Uuery.

. GJT J?- )D K/-?JTK?)>

Jns: Ealue 670 ?ef 67 is )D operator. 6 Psed with KVects 7

 %. -5/DJI \J\0\)K-\0\JDD\0\-5I)T)\ K/-?JTK?)>

  Jns: A!3: The Jny 6or it;s synonym )K-7 operator computes the lowest

(alue from the set and compares a (alue to each returned y a su Uuery.

All' JDD compares a (alue to e(ery (alue returned y )D.

Exi)t)' This operator produces a XKKDJ results. If a su Uuery

produces any result then it e(aluates it to T?P- else it e(aluates it to BJD)-.

Page 37: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 37/62

37MADHAV K

'. GJT I) J K??-DJT-" )PX P-?0 GK IT I) "IBB-?-T B?K J K?JD

)PX P-?>

Jns: J correlated suUuery is a nested suUuery0 which is eecuted once

for each andidate row; y the main Uuery0 which on eecution uses a (alue from a columnin the outer Uuery. In normal su Uuery the result of inner Uuery is dynamically sustituted

in the condition of the outer Uuery where as in a correlated suUuery0 the column

(alue used in inner Uuery refers to the column (alue present in the

outer Uuery forming a correlated suUuery.

 !#. GJT I) J KI + T/-) KB KI)>

Jns: J Voin is used to comine two or more tales logically to get

Uuery results.

There are four types of oins namely

-PI oin

  K+-PI oin

  )-DB oin

KPT-? oin.

  !1. GJT J?- IIP ?-PI?--T) BK? J -PI+KI>

Jns: There shold e atleast one common column etween the Voining tales.

  !2. GJT I) "IBB-?-- X-T-- D-BT0 ?IHGT KPT-? KI>

Jns:If there r any (alues in one tale that do not ha(e corresponding (alues in the other0inan eUui Voin that row will not e selected.)uch rows can e forcefully selected y using outer

 Voin symol6,7 on either of the sides6left or right7 ased on the reUuirement.

!3. GJT I) "IBB-?-- X-T-- -PI J" )-DB KI)>

Jns: )-DB KI is made within the tale whereas

Page 38: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 38/62

Page 39: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 39/62

39MADHAV K

  !. GJT I) "IBB-?-- X-T-- J5 67 J" H?-JT-)T 67 BPTIK)>

Jns: J5 is an aggregate function which takes only one column name of a tale as

parameter whereas Hreatest is a general function which can take any numer of (alues and

column names from dual and tale respecti(ely.

  !%. GJT BK? ED 67 BPTIK I)>

Jns: ED Bunction helps in sustituting a (alue in place of a PDD.

  !'. GJT BK? "-K"- 67 BPTIK I)>

Jns: It is sustitutes (alue asis and it actually does an

^if+then+else^ test.

  #. GJT I) "IBB-?-- X-T-- T?J)DJT- 67 J" ?-/DJ- 67 BPTIK)>

Jns: Translate67 is a superset of functionality pro(ided y ?eplace67.

  1. GJT I) "IBB-?-- X-T-- )PX)T? 67 J" I)T? 67 BPTIK)>

Jns: )ustr67 will return the specified part of a string whereas

Instr67 return the position of the specified part of the string.

  2. GJT I) J PDIJ "J PX-?>

Jns: It will return count of the no. Kf days etween anuary 10 412 X

and the gi(en date.

  3. GK TK "I)/DJ TI- B?K J "JT- "JTJ>

Jns: Xy using time format as ^hh Ahh24F: mi: ss^ in to[char67 function.

Page 40: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 40/62

40MADHAV K

  4. GK TK I)-?T "JT- J" TI- ITK J "JT- KDP>

Jns: Xy using format ^dd+mon+yy hh Ahh24F: mi: ss^ in to[date67 function.

  . GJT I) "IBB-?-- X-T-- TK["JT- 67 J" TK[GJ? 67 KE-?)IK

BPTIK)>

Jns: To[date con(erts character date to date format whereas

To[char function con(erts date or numerical (alues to characters.

  !. GJT I) J EI-> GK IT I) "IBB-?-T B?K J TJXD->

Jns: Eiew is dataase oVect0 which eists logically ut contains no

physical data and manipulates the ase tale.

Eiew is sa(ed as a select statement in the dataase and contains no

physical data whereas Tale eists physically.

  . GJT I) "IBB-?-- X-T-- )I/D- J" K/D-5 EI-)>

Jns: )imple (iews can e modified whereas omple (iews 6created ased

on more than one tale7 cannot e modified.

  %. GJT I) J IDI- EI->

Jns: Inline (iew is asically a suUuery with an alias that u can use

like a (iew inside a )D statement. It is not a schema oVect like )D+oVect.

  '. GK TK P/"JT- J K/D-5 EI->

Jns: Psing ^I)T-J" KB^ T?IHH-?) omple (iews can e Ppdated.

  %#. GJT BK? \ITG G-W K/TIK\ BK? J EI->

Page 41: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 41/62

41MADHAV K

Jns: \ITG G-W K/TIK\ clause specifies that inserts and updates r performed through

the (iew r not allowed to create rows which the (iew cannot select and therefore allows

integrity constraints and data (alidation checks to e enforced on data eing inserted or

updated.

%1. GJT I) J I"-5> J"EJTJH- KB J I"-5

Jns: Jn Inde is a dataase oVect used n Kracle to pro(ide Uuick

access to rows in a tale. Jn Inde increases the performance of the dataase.

  %2. GJT I) J )-P--> /)-P"K+KDP) J))KIJT-" ITG )-P-->

Jns: )eUuence is a "ataase KVect used to generate uniUue integers to use as primary

keys. et(al0 urr(al are the /seudo olumns associated with the seUuence.

99%3. GJT I) J DP)T-?> G- TK P)- J DP)T-?> GK TK "?K/ J DP)T-?

G- DP)T-?-" TJXD- -5I)T)>

Jns: luster and Indees are transparent to the user. lustering is a

method of storing tales that are intimately related and are often Voined together into the

same area on the disk.

hen cluster tale eists then to drop cluster we ha(e to drop the tale first then onlycluster is to e dropped.

  %4. GJT I) J )J/)GKT K? JT-?IJDI-" EI->

Jns: ateriali@ed (iews can e used to replicate data. -arlier the data

was replicated through ?-JT- )J/)GKT command. ow ?-JT- JT-?IJDI-" EI-

can e used as synonym for ?-JT- )J/)GKT. uery performance is impro(ed using the

materiali@ed (iew as these (iews pre calculate epensi(e Voins and aggregate operations on

the tale.

%. GJT I) J )K>

Jns: J )ynonym is a dataase oVect that allows you to create alternate names for Kracle

tales and (iews. It is an alias for a tale0 (iew0 snapshot0 seUuence0 procedure0 function or

Page 42: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 42/62

Page 43: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 43/62

43MADHAV K

among the pri(ileges he<she has.

  '3. GK TK GJH- /J))K?" KB J P)-?>

Jns: Psing /assword command or

Psing JDT-? P)-? Nuser name* I"-TIBI-" X Nnew password* KJ".

'4. GJT I) J )G-J J" )G-J KX-T)>

Jns: J schema is a collection of logical structures of data0 or schema

oVects. J schema is owned y the dataase user and has the same name as that of user.

-ach user owns a single schema. )chema oVects include following

type of oVects lusters0 "ataase Dinks0 Bunctions0 Indees0 /ackages0

/rocedures0 )eUuences0 )ynonyms0 Tales0 "ataase Triggers0 Eiews.

  99'. GK TK )TJ?TP/ J" )GPT"K K?JD- "JTJXJ)->

Jns: )tartup and )hutdown Kracle dataase can e done y only the

administator. )tartup is done y using )TJ?TP/ command and )hutdown is done y

)GPT"K command

'!. GJT I) J )-))IK>

Jns: The period etween Dogin and Dogoff on schema.

  '. GJT I) J DI-T /?K-))> GJT I) J )-?E-? /?K-))>

Jns: ref: 12 & J.

  '%. GK TK JW- -E-? "D K/-?JTIK J) JPTK KIT>

Jns: Xy using )-T JPTKKIT K command.

Page 44: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 44/62

44MADHAV K

  ''. GK TK "I)/DJ "JTJ /JH- I)- I )D>

Jns: Xy using )-T /JP)- K command.

1##. GK TK GJH- DI- )I-0 /JH- )I- J" )D /?K/T>

Jns: Xy using )-T DI-)I- N(alue*0 )-T /JH-)I- N(alue*0

)-T )D/?K/T Nnew prompt*.

1#1. GK /D<)D I) "IBB-?-T B?K )D>

Jns: )D is non+procedural language whereas /D<)D is procedural

language that includes features and design of programming language.

1#2. GJT I) J?GIT-TP?- KB /D<)D>

Jns: Hi(e picture & -plain

1#3. GJT I) J /D<)D XDKW>

Jns: "-DJ?-

Ndeclarations*

X-HI

  N-ececutale )tatements*

-5-/TIK

  N-ception Gandler6s7*

-"

1#4. GJT J?- "IBB-?-T T/-) KB /D<)D XDKW)>

Jns: "-DJ?- XDKW: In this lock all the declarations of the (ariale

used in the program is made. If no (ariales are used this lock will ecome optional.

Page 45: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 45/62

45MADHAV K

  X-HI XDKW: In this lock all the eecutale statements are

placed. This lock is andatory.

  -5-/TIK XDKW: In this lock all the eceptions are handled.

This lock is also (ery optional.

  -": -(ery egin must e ended with this -" statement.

  A!o!3"ou) S Na"e& >loc,)

1#. GJT J?- K/K)IT- "JTJ T/-)>

Jns: ?ecords0 Tales are two omposite data types.

1#!. GJT I) )K/- KB J EJ?IJXD- I /D<)D XDKW>

Jns: The (isuaility and accessiility of a (ariale within the

lock6s7 is called scope of a (ariale.

1#. GJT I) J -)T-" XDKW>

Jns: J lock within a lock is called ested Xlock.

1#%. GJT I) J /D<)D -HI->

Jns: The /D<)D engine accepts any (alid /D<)D lock as input0 eecutes the procedural

part of the statements and sends the )D statements to the )D statement eecutor in the

Kracle ser(er.

1#'. GJT I) "-BJPDT EJDP- BK? J P-?I /D<)D EJ?IJXD->

Jns: PDD

11#. GJT I) "IBB-?-- X-T-- )I/D- DKK/ J" J BK? DKK/>

Jns: )imple reUuires declaration of (ariales used in it and eit

Page 46: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 46/62

Page 47: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 47/62

47MADHAV K

11!. GJT I) J -5-/TIK> GK IT I) "IBB-?-T B?K -??K?>

Jns: hene(er an error occurs -ception raises. -rror is a ug whereas the -ception is a

warning or error condition.

11. J- )K- XPIDT+I -5-/TIK).

Jns: Too[any[?ows0 o["ata[Bound0 ero["i(ide0 ot[Dogged[Kn

  )torage[-rror0 Ealue[-rror etc.

11%. GK TK ?-JT- J P)-?+"-BI-" -5-/TIK>

Jns: Pser+"efined -ception is created as follows:

  "-DJ?-

Neception name* -5-/TIK

+ + + + + + + + +

  + + + + + + + + +

X-HI

  + + + + + + + + +

  + + + + + + + + +

?JI)- Neception name*

-5-/TIK

G- Neception name* TG-

  + + + + + + + + +

  + + + + + + + + +

-"

11'. GJT I) \KTG-?)\ -5-/TIK>

Page 48: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 48/62

Page 49: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 49/62

49MADHAV K

12!. "K-) K?JD- )P//K?T) /?K-"P?- KE-?DKJ"IH>

Jns: K.

12. GJT I) J /JWJH- J" /JWJH- XK">

Jns: /ackage is declarati(e part of the functions and procedures stored

in that package and package ody is

the definition part of the functions and procedures of that package.

12%. GJT I) J"EJTJH- KB /JWJH- KE-? /?K-"P?- K? BPTIK>

Jns: /ackages pro(ides Bunctions or /rocedures K(erloading facility and

security to those Bunctions or

/rocedures.

12'. I) IT /K))IXD- TK GJE- J /?K-"P?- J" J BPTIK ITG TG- )J-

J->

Jns: K if it is out side a /ackage0 -) if it is within a /ackage.

13#. "K-) K?JD- )P//K?T) ?-P?)IE- BPTIK JDD)>

Jns: -).

131. GJT I) J T?IHH-?> GK IT I) "IBB-?-T B?K J /?K-"P?->

Jns: Trigger: J Trigger is a stored /D<)D program unit associated

with a specific dataase tale.

/rocedure: J /rocedure is to e eplicitly called y the user

whereas Triggers are automatically called implicitly

y Kracle itself whene(er e(ent Kccurs.

Page 50: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 50/62

50MADHAV K

132. GJT I) "IBB-?-- X-T-- J T?IHH-? J" J K)T?JIT>

Jns: onstraints are always T?P- whereas Triggers are KT always T?P-

and onstraints has some limitations whereas Trigger has no limitations.

133. GJT J?- "IBB-?-T -E-T) BK? J T?IHH-? J" TG-I? )K/-)>

Jns: Insert0 Ppdate or "elete.

134. GJT I) "IBB-?-- X-T-- TJXD- D-E-D J" ?K D-E-D T?IHH-?)>

Jns: Tale le(el Triggers eecute once for each tale ased transaction

whereas ?ow le(el Triggers will eecute once BK? -JG ?K.

99 13. GJT J?- JPTKKKP) T?IHH-?)>

Jns: )upports to pro(ide ommit statement in Triggers. Triggers a declared as independent

  Transactions.

13!. GJT I) J \I)T-J" KB\ T?IHH-?>

Jns: These Triggers are used with the omple Eiews only to make

possile of Insert0 Ppdate and "elete on those Eiews.

99 13. GK J T?IHH-?) J X- KBIHP?-" K J TJXD- J" EI->

Jns: 1% Triggers

13%. GJT I) \TJXD- PTJTIH\ -??K?> GK TK )KDE- IT>

Jns: K?J+#4#'1: Tale name is mutating0 trigger<function may not see it

Page 51: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 51/62

51MADHAV K

ause : J trigger or a user+defined /D<)D function that is referenced

in the statement attempted to Uuery or modify a tale that was in the middle of eing

modified y the statement that fired the trigger.

Jction : ?ewrite the trigger or function so it does not read the tale.

13'. G- TK P)- \:-\ J" \:KD"\ )/-IBI-?)>

Jns: The prefi :old is used to refer to (alues already present in the

tale. The prefi :new is a correlation name that refers to the new (alue that is inserted <

updated.

99 141. GK TK ?-JT- J P)-?+"-BI-" EJ?IJXD- I /D<)D>

Jns: "efine (ariale in declaration section

142. GK TK ?-JT- J J??J EJ?IJXD- I /D<)D>

Jns: Psing ?-JT- AK? ?-/DJ-F T/- Ntype name*

J) EJ??J 6si@e7 KB -D--T[T/- 6KT PDD7 ommand

99143. GK TK JW- J P)-?+"-BI-" "JTJ T/- HDKXJD I /D<)D>

Jns: "eclare the (ariale in a /ackage

144. GK TK ?-JT- J KX-T I K?JD->

Jns: Psing ?-JT- AK? ?-/DJ-F T/- Ntype name* J) KX-T 6JTT?IXPT-

J- "JTJ T/-0..7 ommand

14. GJT I) J T?J)I-T J" /-?)I)T-T KX-T>

Jns: The KVect created in a tale is called /ersistent KVect.

  KVect created on eecution of /D<)D lock is called Transient KVect.

Page 52: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 52/62

52MADHAV K

9914!. GJT I) J KDP KX-T J" TJXD- KX-T>

Jns: J olumn KVect is only a olumn of a tale.

14. GK TK H?JT /-?I))IK K J KX-T TK KTG-? P)-?>

Jns: H?JT Npermission* K NoVect name* TK Nuser name*.

14%. GJT I) J KDD-TIK KB K?JD->

Jns: Earray0 ested Tale is a collection of Kracle.

14'. GJT I) "IBB-?-- X-T-- EJ??J J" -)T-" TJXD->

Jns: Earray has a fied si@e.

  ested tales can carry any numer of (alues.

1#. GK TK K"IB KT-T) KB J EJ??J I K?JD->

Jns: To modify a stored EJ??J it has to selected into a

  /D<)D (ariale and then inserted ack into the tale.

11. GJT I) P)- KB \TG-\ K/-?JTK? BK? -)T-" TJXD->

Jns: TG- operator allows nested tales to e manipulated using "D when

it is stored in a Tale.

12. GIG /JWJH- I) P)-" BK? BID- I/PT<KPT/PT I K?JD->

Jns: PTD[BID- /ackage is used for Bile input<output in Kracle.

Page 53: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 53/62

53MADHAV K

13. J- )K- -TGK") J" /?K-"P?-) KB BID- I<K /JWJH->

Jns: BK/-0 BDK)-0 BBDP)G0 I)[K/-0 H-T[DI-0 /PT[DI-0 /PTB0 -[DI-

 

9914. GJT I) )D> GK IT I) "IBB-?-T B?K "X K-TIEIT>

Jns: )D is asically a a(a program containing emedded static )D

statements that are compatile with a(a design philosophy.

1. GJT I) J IT-?JTK?> ame some T/-) KB IT-?JTK?)>

Jns: )D Iterators are asically record groups generated during

transaction0 which reUuires manipulation of more than one records from one or more tales.

There are two types Iterators namely amed Iterator and /ositional Iterator.

99 1!. GJT J?- "IBB-?-T )T-/) TK ?IT- J "JI )D /?KH?J>

Jns: -g: char c[sUlstringAFY_L"-D-T- B?K sailors G-?- rating*M`

-5- )D /?-/J?- readytogo B?K :c[sUlstring

-5- )D -5-PT- readytogo

1. GJT I) TJXD- /J?TITIKIH J" I"-5 /J?TITIKIH>

Jns: Kracle% allows tales and Indees to e partitioned or roken up into smaller parts

ased on range of key (alues. /artitioning is a Ldi(ide and conUuerM strategy that impro(es

administration and performance in data warehouse and KDT/ systems.

1'. GJT I) /G)IJD -K? )T?PTP?- KB K?JD->

Jns: The asic oracle memory structure associated with Kracle includes:

)oftware ode Jreas The )ystem Hloal Jrea 6)HJ7 0The "ataase Xuffer ache

The shared /ool0 The /rogram Hloal Jreas 6/HJ70 )tack Jreas 0"ata Jreas0 )ort Jreas

1!#. GJT I) DKHIJD -K? )T?PTP?- KB K?JD->

Page 54: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 54/62

54MADHAV K

Jns: "ataase0 Talespace 0 "X KVect0 )egment0 -tents

1!1. GJT I) 7GA>

Jns: J )ystem Hloal Jrea is a group of shared memory allocated y

Kracle that contains data and control information for one Kracle dataase instance. IB the

multiple users are concurrently connected to the same instance0 the data in the instance;s

)HJ is LsharedM among the users.

onseUuently0 the )HJ is often referred to as either the Lsystem Hloal JreaM or the

 L)hared

Hloal JreaM.

1!2. GJT I) PGA>

Jns: The /rogram Hloal Jrea is a memory uffer that contains data and

control information for a ser(er process. J /HJ is created y Kracle when a ser(er process

is started. The information in a /HJ depends on the configuration of Kracle.

1!3. GJT I) J K?JD- I)TJ->

Jns: -(ery time a dataase is started0 an )HJ is allocated and Kracle

ackground processes are started. The comination of these processes and memory uffers

is called an Kracle instance.

1!4. GJT J?- "IBB-?-T K?JD- /?K-))-)>

Jns: J process is a Lthread of controlM or a mechanism in an operating

system that can e eecute a series of steps. )ome operating systems use terms Vos or

task. J process normally has its own pri(ate memory area in which it runs. Jn Kracle

dataase system has general types of process: Pser /rocesses and Kracle /rocesses.

991!. GJT I) "IBB-?-- X-T-- /K J" )K>

Jns: )K 6)ystem onitor7 performs instance reco(ery at instance of

Page 55: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 55/62

55MADHAV K

startup. In a multiple instance system 6one that uses the parallel ser(er70 )K of one

instance can also perform instance reco(ery other instance that ha(e failed whereas The

/K 6/rocess onitor7 performs process reco(ery when a user process fails.

991!!. GJT I) "IBB-?-- X-T-- "JTJXJ)- J" TJXD-)/J->

Jns: "ataase is a physical omponent

  Talespace is a Dogical component

1!. GJT I) KX KB "JTJXJ)- ?IT-? 6"X?7 /?K-))>

Jns: The "ata Xase riter writes modified locks from the dataase

uffer cache to the data files.

1!%. GJT I) KX KB DKH ?IT-? 6DH?7 /?K9))>

Jns: The Dog riter writes redo log files to disk. ?edo log data is

generated in the redo log uffer of the )HJ. Js transactions commit and log uffer fills0

DH? writes redo entries into an online redo log file.

1!'. GJT I) ?-KE-?-?>

Jns: The ?eco(er 6?-K7 is used to resol(e distriuted transactions that are pending due to

network or system failure in a distriuted dataase. Jt timed inter(als0 the local ?-K

attempts to concept to remote dataase and automatically complete the commit or rollack

of the local portion of any pending distriuted transactions.

1#. GJT I) J?GIE-?>

Jns: The Jrchi(er 6J?G7 copies the online redo log files to archi(al storage when they are

full. 0J?G is acti(e only when a dataase;s redo log is used J?GIDKH mode.

99 11. GJT I) J )TK?-" P-?>

Jns: EI-

Page 56: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 56/62

56MADHAV K

12. GJT I) P)-? /?K-)) J" )-?E-? /?K-))>

Jns: J Pser process is created and maintained to eecute the software

code of an application program 6such as /?K 9 /rogram7 or an K?JD- tool 6such as )D 9

"XJ7. The Pser process also manages the communication

with ser(er processes. Pser processes communication with the ser(er

/rocesses through the program interface.

 Kther processes call K?JD- processes. In a dedicated ser(er

configuration0 a ser(er /rocess handles reUuests for a single user process. J multithread

ser(er configuration allows many user processes to share a small numer of ser(er

processes0 minimi@ing the utili@ation of a(ailale system resources.

9913. GJT I) J )-DB ?-B-?-TIJD IT-H?IT>

Jns: Tale related to itself .Boreign key of the tale links to primary key of the same tale.

14. GJT I) J \?JI)-\ )TJT--T>

Jns: It is used to ?aise -ceptions.

1. GJT I) ?KI"> GK IT I) "IBB-?-T B?K ?KP>

Jns: ?owid is the address of the row at where it is stored in the

dataase. ?ownum is count of records whereas ?owid is identification of the each row.

All The >e)t + 7%#DA%

'i features:

'i oins:

)upports J)I<I)K standard )Ul 1''' synta

Page 57: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 57/62

Page 58: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 58/62

58MADHAV K

  on6e.deptno Y d.deptno7

99 left outer Voin union right outer Voin Y full outer Voin

%. * select empno0ename0sal0Vo0deptno0dname0loc

  from emp cross Voin dept

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

ew "ate Bunctions:

9 )ystimestamp : Hi(es date and time including fractional seconds in )-?E-? time @one

9 current[timestamp: Hi(es date and time including fractional seconds in DI-T time @one

9 sysdate: Hi(es only date in ser(er time @one

9 current[date: Hi(es only date in client time @one

9 -tract : Psed to retrie(e a particular (alue from the gi(en date 6 day <

month < year 7.

9 to[timestamp6d7 : on(erts gi(en date into date & time

information with am < pm .

9 dtime@one : Hi(es ser(er time @one (alue

9 Timestamp : "ata type

Jutomatically stores date and time information with am < pm .

*select systimestamp 0 current[timestamp from dual

*select sysdate0current[date from dual

*select dtime@one from dual

*select to[timestamp6sysdate7 from dual

  2#+Van+#' !:4%:23 pm

*select etract6day from sysdate7 0

 etract6month from sysdate70

 etract6year from sysdate7 from dual

Page 59: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 59/62

59MADHAV K

 create tale temp 6c1 timestamp7

* insert into temp (alues6sysdate7

* select 9 from temp

 2#+Van+#' !:2:23 pm

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

ew Heneral Bunctions:

9 oalesce6epr10epr20epr30.......7 +++ /icks the first not null epression result .

9nullif 6 epr10epr2 7 +++ If epr1 and epr2 results are same it returns PDD (alue

otherwise it return epr1 result.

9 (l26epr10epr20epr37 +++ If epr1 is null it manipulates epr3 0if epr1 is not null itmanipulates epr2.

*select coalesce61## , null0 12% + null , 1###0 12 9 null0

  220 2340'%%'7 from dual ++ 22

*select ename0 Vo0 coalesce 6comm 9 20 sal 9 1.7 onus

 from emp

*select nullif61##0#9 270 nullif63##03# 9 1##70

  nullif 6!##03## , 3##7 from dual ++ null 3## null

*select roll0 name0 nullif6fee02##7 from student

  where course Y ^Kracle'i^

*select ename0 Vo0 n(l26comm0sal , comm0sal7 net from emp

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

utiple Inserts:

Page 60: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 60/62

60MADHAV K

)upports to insert into more than 1 tale at a time.

Xut input must e retrie(ed from eisting tale.

-: ake 3 empty tales same as "ept tale.

reate tale "1 as select 9 from dept

where rownum is null

reate tale "2 as select 9 from dept

 where rownum is null

reate tale "3 as select 9 from dept

where rownum is null

insert into "1 select 9 from dept

insert into "2 select 9 from dept

insert into "3 select 9 from dept

insert all

into "1 (alues6deptno0dname0loc7

into "2 (alues6deptno0dname0loc7

into "3 (alues6deptno0dname0loc7

select 9 from dept

onditional Insert:

insert all

when 6deptno NY 4#7 then

into "1 (alues6deptno0dname0loc7

when 6deptno NY '#7 then

into "2 (alues6deptno0dname0loc7

Page 61: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 61/62

61MADHAV K

else

into "36dname0loc7 (alues6dname0loc7

select 9 from dept

insert all

when course Y ^Kracle'i^ then

into stu[oracle (alues6roll0name0fee7

when course Y ^d!i^ then

into stu[d!i (alues6roll0name0fee7

when course Y ^uni^ then

into stu[uni (alues6roll0name0fee7

select 9 from student

)tudent stu[oracle

+++++++++ ++++++++++++

?oll ?oll

name name

course fee

fee

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

erge :

Psed to compare the 2 tale contents and makes them eUual.

It supports only Ppdate and Insert operations .

*merge lauses:

into Temp T into ++ Target

using emp - Psing ++ )ource

Page 62: UNIX Shell-Scripting Basics Complete Commands

8/12/2019 UNIX Shell-Scripting Basics Complete Commands

http://slidepdf.com/reader/full/unix-shell-scripting-basics-complete-commands 62/62

62MADHAV K

on 6 T.empno Y -.empno 7 Kn ++ oin condition

when matched then

update set t.sal Y e.sal0

  t.comm Y e.comm0

  t.deptno Y e.deptno0

  t.Vo Y e.Vo0

  t.mgr Y e.mgr

when not matched then

insert (alues6e.empno0e.ename0e.sal0e.comm0......7

Xefore :

-mp + 1 rore rows

Temp + opy of emp + 1 rore rows

Jfter :

-mp +++ ### inserts & 1### Ppdates performed

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

?ename onstraint & olumn :

Jlter tale emp rename constraint sys[c##232 to pk[emp

Jlter tale emp rename column ename to emp[name

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

'i )upports :

Jd(anced Beatures of JEJ

Impro(ed internal Jrchitecture related to JEJ

)upports 5D.