Professional Documents
Culture Documents
MADHAV K
2
MADHAV K
UNIX COMMANDS
1. $ LOGNAME
2. $PWD
3. $DATE
4. $clear
5. $cal
6. $cal 2000
7. $cal 8 2006
8. $exit or logout
9. $ who
10. $finger
more information
: displays the all user who are currently working on server with
11. Who am I
My Commands:
Du sk filename : to find the size of one file
Du sk test.txt
Du sk filename1 filename2 . : to find size of multiple files
Du sk test.txt test2.txt
Du a
3
MADHAV K
E:\files in ds>du -h
512B ./In Bound/testing_UNIX
14.50KB ./In Bound
153.50KB ./Out Bound
327.00KB .
How to find all the files in all the directories in that folder?
Suppose Files in Ds is the folder which has so many files and also 2 Folders In
Bound and Out Bound. We want the files present in In Bound and also Out bound,
In that case what needs to be used?
Ls R
---------------------cntl+d
Open file: cat <filename-----open single file
multi files
4
MADHAV K
Cat >.filename---------for hidden files
14. Touch
: creating directories
: change directory
Sys: $cd abc
$pwd------/home/madhav/abc using above cmd we can come out from abc now we
at //home/madhav
cd..---------------------------to come out from current directory
cd../..------------------------parent directory
cd/---------------------------it changes to root directory
5
MADHAV K
cd ~-------------------------it changes to home directory
18. cp
Ex
Cp emp1 emp2----------------------emp1 tp 2 coping
Cp I m1 m2-------------------------overwrite confirmation? Y
Cp R source directory to target directory-------cp R abc xyz
19. mv
21.ls|more
22. ls a
: display, list of all files & directories including hidden files and
dirctories also in current directory
23. ls r
: display list of all files & directories revers order in a current directory
24. Ls R
25. Ls t
current directory
26. Ls F
directory
: display all list of files & directories, link files, .exe files in a current
27. Ls-x
current directory
28. Ls-L
i.e. 9 fields
: display all list of files & directories in a current directory in a long list
1) File types
6
MADHAV K
[1) -- For regular file ii) dfor dir file III) Lfor link file IV) bfor
block of filesV) c for char files] [here IV, V is device files]
2) File permissions 3) no. of links 4) owner name 5) group name 6) file size in bytes
7) Date 8) time 9) filename
30. cmp
34. more
34. head
35. tail
7
MADHAV K
Syn: $wc filename
i) wc l filename------------------it gives the no of lines in a given file
ii) wc w filename---------------it gives the no of words in a given file
III) wc c filename--------------- it gives no. of char in file
iv) wc -lw filename-------------- it gives the no of lines and character in a given file
8
MADHAV K
7th line
ii) Eg: $grep madhav a1, a2, a3:
a1:-----a2:-----a3:-----iii) $ grep techno *------it searches for techno in current dir files (all files)
iv) $grep techno soft sample-----it searches for more than one word
We kept it in
/>
9
MADHAV K
Grep /<techno/> sample ------------o/p: techno
Grep /<techno sample----------------o/p: techno soft
-----------------o/p: techno 123
Grep techno/> sample
10
MADHAV K
Mv temp sample-------------------here both are delete empty files
This command is used to show the After 3 lines when the string is found
Grep A 3 i Chandra emp.txt
This command is used to show the Before 3 lines when the string is found
Grep B 3 I se emp.txt
If the no.of lines found are not exactly same as the lines found then it will result the
lines that it found.
39. fgrep
expression
: it is used for search multiple strings but it doesnt allow to search regular
$grep hello
>techno
>UNIXsample----------it searches for hello or techno str UNIX
40. egrep
$egrep hello
>hello
>UNIXsample
41. Sed
$egrep ^$ sample
: to replace a string
$ sed s/existing string/new string/g filename--sed is used to find and replace and grep
is for find print
Here g is to state that replace existing string with new string Globally. If we want to replace
only second instance then
Sed s/ existing string/new string/2
We can use any delimiter to replace the command
Sed s| existing string| new string |g
We can replace the string in only one particular line
Sed 3 s| existing string| new string |g
11
MADHAV K
We can replace range of lines by using below command
Sed 1,3 s| existing string| new string |g
: to translate a charctor
i) tr a p <s-------------------- it read data from sample and a is replaced by p
ii) tr aeiou AEIOU<sample----replace char by char
iii) tr , lt <emp----------------whenever , is there replace with tab space
iv) tr [a-z] [A-Z] <Siva-------- converts hole file into uppercase
43) Cut
: it is used for to retrieve required fields and characters from a given file
12
MADHAV K
Ex: madhav is good boy--18 chars
Cut f 2-5 madhav---o/p: adha
Cut c 1-10 madhav
Cut c 5-10, 15-20 madhav-------for every line 5-10, 15-20 characters
Cut c 1,2,3 emp.txt Prints 1,2 and 3rd char of each line
Cut c 1-3,4-6 emp.txt prints 1 to 3 and 4 to 6 character of each line
Cut c10- emp.txt Print the lines from 10th to end position by using cut
command
We can print the lines by using delimiter
Cut d, f2 emp.txt This will print the 2nd word of each line by taking , as
delimiter.
Cut d, f2,3, emp.txt This will print the 2nd and 3rd words of each line by
taking comma as delimiter.
44) Paste
Cat >states
filename
cat >cities
AP
Hyderabad
AP: Hyderabad
Tamilnadu
madras
Tamilnadu: madras
Karnataka
Bangalore
Karnataka: Bangalore
Kerala
Trivandrum
Maharashtra
Bombay
45) Sort
: it is used for to sort the file content. By default it sorts file contents based
on ASCII values-default is ascending
Sort sample
i) sort r sample------displays descending order
13
MADHAV K
ii) sort u sample-----it displays unique lines in the given file
iii) sort n file----N numeric comparisons
iv) sort nur file
v) sort sample >temp
$mv temp sample
Sorting the data field by field
+pos--starting field
-Pos--ending field (optional)
i) Sort f +pas1 pas2 filename
ii) Sort f +1 -3 filename-----starting from end before 3
iii) Sort fn +2 -3 file ------it gives only numbers
46) Uniq
order
: it displays unique lines in the given file but the file contents should be in sort
Ex:file1
Aaaaaa
i) $ uniq file
Aaaaaa
Aaaaaa
ccccc
Aaaaaa
cccccccc
ddddd
Ccccccc
dddddd
Ppppp
Ddddd
hhhhhh
ttttttt
Hhhhh
pppppp
Hhhhh
ttttttttt
Ppppp
Ttttttt
iii) $ Uniq d filename----displays only duplicated lines
how many times lines duplicated
Aaaaaa-----2
Cccccccc----1
14
MADHAV K
V) $ uniq u file >temp
$ mv temp filename
Delete duplicated lines from file
Ddddd-----1
Hhhhhh---2
Ppppp-----1
Ttttttt-----1
47)piping(|)
: it is used for to combine 2 or more cmds |take left side o/p to right
side cmd as i/p
i) $who |wc l---------count total no of lines (files) in current directory
ii) $ ls|wc l------------displays total no of subdirectories in the current directory
iii) ls l |grep ^d----displays total no of subdirectories who stats with line nod
iV) $head -30 sample|tail +20 sample------display the the lines from 20 to 30 from
given file
v) $ grep UNIX stud | cut f 2, 3|sort filename -----display UNIX students names & ph
no in ascending order
48) $tee
15
MADHAV K
53) Unalias alias names: to delete alias names
54) $ history
55) Echo
File permissions:(xxx/xxx/xxx)
User/owner---permissions
(first part)
Group permissions
(second part)
Other permissions
(third part)
+--- (add permissions to u/g/o but it does not delete exiting permission)
--- (deny permissions)
=---- (assign permissions (add permissions to u/g/o but it delete exiting
permission))
rw-/rw-/r-- ---------Default permissions for regular files
rwx/rwx/r-x---------default permission for directories
56) chmod
16
MADHAV K
58) chgrep
: it is user for to with the users but the user shxould be logged into the
$write techno2
Hello
Cmtl+d
59) awk/nawk file
60) cat
61) chsh (paawd e/-s) userlogin_shell: change the user login shell
62) df
: report the summary of disk blocks and nodes free and in use
i) df k---it displays the disk space in bytes
ii) df h---it displays disk space in kilo bytes
iii) df g---it displays the disk space in giga bytes
63)du :it displays the directory wise disk usage in form of blocks each block size is 512
bytes
64)g zip
: it also used for to zip the file---it used to save with .z format
67) Uncompress
: same as above
17
MADHAV K
$zcat sample.gz
Or
$zcat sample.z
69) To kill foreground job cntl+c or cntl+z
$ sleep 500
Cntl+c
$ sleep 100&
70) ps or $ ps f
active process)
74) ftp: file transfer protocol -----transfer files from one server to another
$ ftp ipaddress
Login: ------Password: -----Ftp>ls (server)
Ftp>|ls(client)
Ftp>get filename (to download a file)
Ftp>mget file1 file2----- (to download multi files)
Ftp>put filename (to upload a file)
Ftp>mput file1 file2----- (to upload multi files)
75)Ftp: to transfer files from one server user account to another server user account
$su root --to switch to admin
76) Wall
: it is used for to sent broadcast message to all users who are
currently working on server
18
MADHAV K
$wall
Happy new-year
Cntl+d
77)mail
mail
:it is used for to send the mail, if user is not logged in then also we can send
i) $ mail techno1
Cntl+d every user contains mailbox
at a time we can send msg to multiple users
2) $mail techno1 techno2 techno 3
Sub: from techno
Cntl+d
iii) $ mail techno<stud
stud send content as a mail to techno3
mail is the cmd to read mails in the mailbox
$mail
1>first mail
2>second mail reading
&2 it quickly opens second mail
&q--quit from mail box
&w to save mail contents to a file
&pprint mail contents
&r--replays
&d-delete mails
78)$mail f:to read mails send to secondary mailbox
79) emacs
80) echo
81) file
19
MADHAV K
82) expr
83) find
84) Hostname
85)ln
86)lpq ,lpstat
87)lpr,lp
89) man
90)od
91)passwd
92) pr
: read cmds from the file and execute them in the current shell
99) Sty
103) jobs
104) kill %1
105) top
106) osview
107) setenv
20
MADHAV K
UNIX
1. Password protection.
2. File permissions.
3. Encryption.
21
MADHAV K
who
How do you find out the current directory youre in?
pwd
What is the command to see the location of command?
Where is <command name>
How do you find out your own username?
Whoami
The file for which we do not have write permission can be deleted using the
command?
rm -f <filename>
How do you remove a directory and its subdirectories?
rm rf <directoryname>
How to rename a file?
Mv <filename>
How to copy multiple files and directories into some other directory?
cp -r source_directory destination_directory
How to see hodden files?
Ls a
How to see files and subdirectories files recursively?
Ls R
How to see files in long list format page wise?
Ls l | more
How to identify whether a file is normal file or directory?
22
MADHAV K
$ls -l filename/directoryname
if the first digit is - then it is file,
if it is d then it is directory file
ls -r lists the files in reverse alphabetical order... whereas ls -R lists the files and directories
recursively
23
MADHAV K
"grep" means
Globally search a regular expression and print it
egrep : accepts more than one pattern for search. Also accepts patterns from a file.
fgrep : accepts multiple patterns both from command line and file but does not accept
regular expressions only strings. It is faster than the other two and should be used when
using fixed strings.
24
MADHAV K
Grep v ^$ filename > temfilename
Mv tempfilename filename
What is pattern to search 4 digit word in a file?
Grep \<[0-9] [0-9] [0-9] [0-9]\> filename
What is pattern to search the line having only three characters?
Grep ^$ filename
What is pattern to display lines ending with $ character in a given file?
Grep \$$ filename
Once you understand the basics of awk you will find that it is surprisingly useful. You can
use it to automate things in ways you have never thought about. It can be used for data
processing and for automating the application of Unix commands. It also has many
spreadsheet-type functionalities.
There are two ways to run awk. A simple awk command can be run from the command line.
More complex tasks should be written as awk programs ("scripts") to a file. Examples of
each are provided below.
Example: % awk 'pattern {action}' input-file > output-file
meaning: take each line of the input file; if the line contains the pattern apply the action to
the line and write the resulting line to the output-file.
25
MADHAV K
If the pattern is omitted, the action is applied to all lines:
The pipeline to list the five largest files in the current directory is
The pipeline to find out the number of times the character ? occurs in the file is
tr -dc '?' < file | wc -c
( Delete all the characters except ? and then make a word count.)
26
MADHAV K
What is the default permission for File & Directory ?
The Default privileges for file : 644
The default privileges for directory : 755
What UNIX command will control the default file permissions when files are
created?
Umask
Explain the read, write, and execute permissions on a UNIX directory.
Read allows you to see and list the directory contents.
Write allows you to create, edit and delete files and subdirectories in the directory.
Execute gives you the previous read/write permissions plus allows you to change into the
directory and execute programs or shells from the directory.
What is chmod, chown and chgrp?
Chmod : It is used for to change permissions on files
Chown : It is used for to change ownership of a file
Chgrp : It is used for to change group of the file
If the owner doesnt have write permission on a file, but his/her group has, can
he/she edit it?
No. He/she can't,because the owner's permission overrides the group's.
To see list of files and directories ,what permission required?
Read permission
What are PIDs?
They are process IDs given to processes. A PID can vary from 0 to 65535.
How do you list currently running process?
ps
How do you stop a background process?
kill pid
How do you find out about all running processes?
ps -ag
How do you stop all the processes, except the shell window?
kill 0
How do you fire a process in the background?
27
MADHAV K
./process-name &
What does the command "kill -9 $! " do?
kills the last background process
if there is a process u want to run even after exiting the shell what is the
command used?
Nohup
which command will get executed even after you log out?
Nohup
28
MADHAV K
Ans. mesg n
The other way of running shell script apart from using sh command and chmod?
ans:- using ! we can run a shell script
19. How do you refer to the arguments passed to a shell script? - $1, $2 and so on. $0 is
your script name.
20. Whats the conditional statement in shell scripting? - if {condition} then fi
21. How do you do number comparison in shell scripts? - -eq, -ne, -lt, -le, -gt, -ge
22. How do you test for file properties in shell scripts? - -s filename tells you if the file is
not empty, -f filename tells you whether the argument is a file, and not a
directory, -d filename tests if the argument is a directory, and not a file, -w
filename tests for writeability, -r filename tests for readability, -x filename tests
for executability
23. How do you do Boolean logic operators in shell scripting? - ! tests for logical not, -a
tests for logical and, and -o tests for logical or.
24. How do you find out the number of arguments passed to the shell script? - $#
25. Whats a way to do multilevel if-elses in shell scripting? - if {condition} then
{statement} elif {condition} {statement} fi
26. How do you write a for loop in shell? - for {variable name} in {list} do
{statement} done
27. How do you write a while loop in shell? - while {condition} do {statement} done
28. How does a case statement look in shell scripts? - case {variable} in {possiblevalue-1}) {statement};; {possible-value-2}) {statement};; esac
29. How do you read keyboard input in shell scripts? - read {variable-name}
30. How do you define a function in a shell script? - function-name() { #some code here
return }
31. How does getopts command work? - The parameters to your script can be passed as -n
15 -x 20. Inside the script, you can iterate through the getopts array as while getopts n:x
option, and the variable $option contains the value of the entered option.
Batch file:
29
MADHAV K
Batch files allow MS-DOS and Microsoft Windows users to create a lists of commands to run
in sequence once the batch file has been executed. For example, a batch file could be used
to run frequently run commands, deleting a series of files, moving files, etc. A simple batch
file does not require any special programming skills and can be done by users who have a
basic understanding of MS-DOS commands.
ORACLE9i FAQs
1.
Ans: The Matter that we feed into the Computer is called Data or Information.
2.
WHAT IS DATABASE?
3.
4.
5.
WHAT IS ORDBMS?
6.
30
MADHAV K
Ans: Dr. E.F. Codd presented 12 rules that a database must obey if it
is to be considered truly relational. Out those, some are as follows
a)
The rules stem from a single rule- the zero rule: For a system to Qualify as
RELATIONAL DATABASE MANAGEMENT system, it must use its RELATIONAL facilities
to MANAGE the DATABASE.
b)
c)
d)
Missing Information Rule: Systematic representation of missing information as NULL
Values.
e)
7.
b) Network Model: The Network Model, also called as the CODSYL database
structure, is an improvement over the Hierarchical mode, in this model concept of parent
and child is expanded to have multiple parent-child relationships, i.e. any child can be
subordinate to many different parents (or nodes). Data is represented by
collection of records, and relationships among data are represented by
links. A link is an association between precisely two records. Many-to-many relationships
can exists between the parent and child.
31
MADHAV K
for explicit parent-child relationships. In RDBMS, data is organized in two-dimensional tables
consisting of relational, i.e. no pointers are maintained between tables.
8.
Ans: Data Modeling describes relationship between the data objects. The
relationships between the collections of data in a system may be graphically represented
using data modeling.
9.
Ans: Entity: An Entity is a thing, which can be easily identified. An entity is any object,
place, person, concept or activity about which an enterprise records data.
Attribute: An attribute is the property of a given entity.
Relationship: Relationship is an association among entities.
10.
WHAT IS ER-MODELING?
Ans: The E-R modeling technique is the Top Down Approach. Entity
relationship is technique for analysis and logical modeling of a systems data requirements.
It is the most widely used and has gained acceptance as the ideal database design. It uses
three basic units: entities, their attributes and the relationship that exists between
the entities. It uses a graphical notation for representing these.
11.
WHAT IS NORMALIZATION?
12.
2NF,
32
MADHAV K
The Third Normal Form
3NF,
13.
WHAT IS DENORMALIZATION?
14.
15.
16.
NON-PROCEDURAL LANGUAGE?
Ans:
Procedural Language NON-Procedural Language
33
MADHAV K
A program in this implements a step-by-step algorithm to solve the
problem. It contains what to do but not how to do .
18.
Ans:
DDL (Data Definition Language)
Create Alter Drop Truncate Rename, Select , Insert Update Delete Merge , Grant Revoke ,
Rollback Commit savepoint
19.
20.
21.
34
MADHAV K
Ans: Truncate Command will delete all the records where as Delete
Command will delete specified or all the records depending only on the condition given.
22.
Ans: Alter command is used to modify the database objects where as the
Update command is used to modify the values of a data base objects.
23.
Ans: Grant and Revoke are the two commands belong to the DCL Category.
24.
Ans: Delete is the efficient command because using this command we can
delete only those records that are not really required.
25.
26.
35
MADHAV K
Ans: A Table can have 1000 columns.
27.
Ans: Char (size), Nchar (size), Varchar2 (size), Nvarchar2 (size) data
types for character values,
Number (precision, scale), Number, Number (n), Float, Float (binary precision) data types
for numerical values, Date data type for date values,
Long, Raw (size), Long Raw, Clob, Blob, Nclob, Bfile for large objects.
28.
Ans:
LOB
LONG
sequential access.
4) Only one LONG column was allowed in a table
29.
36
MADHAV K
30. HOW MUCH MEMORY IS ALLOCATED FOR DATE DATATYPE? WHAT IS DEFAULT
DATE FORMAT IN ORACLE?
31.
Ans:
Datatype
Char
Range
Varchar2 Number
Float
32.
2 GB 4GB
Alter the table specifying new column name to be given and data type.
b)
Then copy the values in the column to be renamed into new column.
c)
33.
ii.
Alter the table column whose size is to be decreased using the same
37
MADHAV K
name and data type but new size.
34.
35.
Ans: Not Null, Unique, Check, Primary Key and Foreign Key or Referential Integrity.
36.
Ans: Unique and Not Null is a combination of two Constraints that can be present any
number of times in a table and cant be a referential key to any column of an another table
where as Primary Key is single Constraint that can be only once for table and can be a
referential key to a column of another table becoming a referential integrity.
37.
Ans: A Primary key created on combination of columns is called Composite Primary Key.
38.
39.
38
MADHAV K
42. WHAT IS CREATED IMPLICITLY FOR EVERY UNIQUE AND PRIMARY KEY
COLUMNS?
Ans: Index.
39
MADHAV K
47. HOW TO DROP A PARENT TABLE WHEN ITS CHILD TABLE EXISTS?
Ans: Using "on delete cascade".
40
MADHAV K
count total no. of rows in a table.
41
MADHAV K
value used in inner query refers to the column value present in the
outer query forming a correlated subquery.
42
MADHAV K
65. WHAT IS DIFFERENCE BETWEEN "UNION" AND "UNION ALL"
OPERATORS?
Ans: UNION will return the values distinctly whereas UNION ALL will
return even duplicate values.
Character Functions:
Chr (x), Concat (string1, string2), Lower (string)
Upper (string), Substr (string, from_str, to_str), ASCII (string)
Length (string), Initcap (string).
Date Functions:
Sysdate, Months between (d1, d2), To_char (d, format)
Last day (d), Next_day (d, day).add_months(d,n), Extract
Conversion Functions:
43
MADHAV K
68. WHAT FOR NVL () FUNCTION IS?
Ans: NVL Function helps in substituting a value in place of a NULL.
44
MADHAV K
Ans: To_date converts character date to date format whereas
To_char function converts date or numerical values to characters.
45
MADHAV K
access to rows in a table. An Index increases the performance of the database.
46
MADHAV K
87. WHAT IS DIFFERENCE BETWEEN "SQL" AND "SQL*PLUS" COMMANDS?
Ans: SQL commands are stored in the buffer whereas SQL*PLUS are not.
47
MADHAV K
94. WHAT IS A SCHEMA AND SCHEMA OBJECTS?
Ans: A schema is a collection of logical structures of data, or schema
objects. A schema is owned by the database user and has the same name as that of user.
Each user owns a single schema. Schema objects include following
type of objects Clusters, Database Links, Functions, Indexes, Packages,
Procedures, Sequences, Synonyms, Tables, Database Triggers, Views.
100. HOW TO CHANGE LINE SIZE, PAGE SIZE AND SQL PROMPT?
Ans: By using SET LINESIZE <value>, SET PAGESIZE <value>,
48
MADHAV K
SET SQLPROMPT <new prompt>.
DECLARE
<declarations>
BEGIN
<Exececutable Statements>
EXCEPTION
<Exception Handler(s)>
END;
49
MADHAV K
105. WHAT ARE COMPOSITE DATA TYPES?
Ans: Records, Tables are two Composite data types.
50
MADHAV K
Close the Cursor.
Value_Error etc.
Zero_Divide,
Not_Logged_On
51
MADHAV K
118. HOW TO CREATE A USER-DEFINED EXCEPTION?
Ans: User-Defined Exception is created as follows:
DECLARE
<exception name> EXCEPTION;
---------;
- - - - - - - - -;
BEGIN
- - - - - - - - -;
- - - - - - - - -;
RAISE <exception name>;
EXCEPTION
WHEN <exception name> THEN
- - - - - - - - -;
- - - - - - - - -;
END;
52
MADHAV K
Ans: A SUBPROGRAM IS A PL/SQL BLOCK, WHICH WILL BE INVOKED BY TAKING
PARAMATERS.
53
MADHAV K
128. WHAT IS ADVANTAGE OF PACKAGE OVER PROCEDURE OR FUNCTION?
Ans: Packages provides Functions or Procedures Overloading facility and
security to those Functions or
Procedures.
133. WHAT ARE DIFFERENT EVENTS FOR A TRIGGER AND THEIR SCOPES?
Ans: Insert, Update or Delete.
54
MADHAV K
134. WHAT IS DIFFERENCE BETWEEN TABLE LEVEL AND ROW LEVEL TRIGGERS?
Ans: Table level Triggers execute once for each table based transaction
whereas Row level Triggers will execute once FOR EACH ROW.
55
MADHAV K
56
MADHAV K
57
MADHAV K
Ans: SQLJ Iterators are basically record groups generated during
transaction, which requires manipulation of more than one records from one or more tables.
There are two types Iterators namely Named Iterator and Positional Iterator.
58
MADHAV K
task. A process normally has its own private memory area in which it runs. An Oracle
database system has general types of process: User Processes and Oracle Processes.
59
MADHAV K
Ans: The Data Base Writer writes modified blocks from the database
buffer cache to the data files.
60
MADHAV K
server configuration allows many user processes to share a small number of server
processes, minimizing the utilization of available system resources.
9i Joins:
Supports ANSI/ISO standard Sql 1999 syntax
Made easy for Appln s/w tools to understand Sql Queries
1. Natural Join
2. Join with Using
3. Join with ON
4. Inner Join
61
MADHAV K
3. > select e.empno, e.ename, e.sal, e.job, e.deptno,d.dname, d.loc from emp e Join dept d
on(e.deptno = d.deptno) ;
4. > select e.empno, e.ename, e.sal, e.job, e.deptno, d.dname, d.loc from emp e Inner Join
dept d
on(e.deptno = d.deptno) ;
5. > select e.empno, e.ename, e.sal, e.job, e.deptno, d.dname, d.loc from emp e left outer
join dept d
on(e.deptno = d.deptno) ;
6. > select e.empno, e.ename, e.sal, e.job, e.deptno,d.dname, d.loc from emp e right outer
join dept d
on(e.deptno = d.deptno) ;
* 7. > select e.empno, e.ename, e.sal, e.job, e.deptno,d.dname, d.loc from emp e full outer
join dept d
on(e.deptno = d.deptno) ;
** left outer join union right outer join = full outer join
62
MADHAV K
* Systimestamp : Gives date and time including fractional seconds in SERVER time zone
* current_timestamp: Gives date and time including fractional seconds in CLIENT time zone
* sysdate: Gives only date in server time zone
* current_date: Gives only date in client time zone
* Extract : Used to retrieve a particular value from the given
month / year ).
date
( day /
63
MADHAV K
*nullif ( expr1,expr2 ) --- If expr1 and expr2 results are same it returns NULL value
otherwise it return expr1 result.
* Nvl2(expr1,expr2,expr3) --- If expr1 is null it manipulates expr3 ,if expr1 is not null it
manipulates expr2.
64
MADHAV K
Create table D3 as select * from dept
where rownum is null;
insert all
into D1 values(deptno,dname,loc)
into D2 values(deptno,dname,loc)
into D3 values(deptno,dname,loc)
select * from dept;
Conditional Insert:
insert all
when (deptno <= 40) then
into D1 values(deptno,dname,loc)
when (deptno <= 90) then
into D2 values(deptno,dname,loc)
else
into D3(dname,loc) values(dname,loc)
select * from dept;
insert all
when course = 'Oracle9i' then
into stu_oracle values(roll,name,fee)
when course = 'd6i' then
65
MADHAV K
into stu_d6i values(roll,name,fee)
when course = 'unix' then
into stu_unix values(roll,name,fee)
select * from student;
Student
stu_oracle
---------
------------
Roll
Roll
name
name
course
fee
fee
---------------------------------------------------------------------------Merge :
Used to compare the 2 table contents and makes them equal.
It supports only Update and Insert operations .
>merge
Clauses:
into Temp T
into -- Target
using emp E
Using -- Source
on ( T.empno = E.empno )
On -- Join condition
66
MADHAV K
insert values(e.empno,e.ename,e.sal,e.comm,......);
Before :
Emp - 1 Crore rows
Temp - Copy of emp - 1 Crore rows
After :
Emp --- 5000 inserts & 1000 Updates performed
---------------------------------------------------------------------------Rename Constraint & Column :
Alter table emp rename constraint sys_c002325 to pk_emp;
Alter table emp rename column ename to emp_name;
---------------------------------------------------------------------------9i Supports :
Advanced Features of JAVA
Improved internal Architecture related to JAVA
Supports XML.