Sie sind auf Seite 1von 3

3/14/2016

PLSQLin21Hours:OracleInterviewBasedQueries4

PLSQL in 21 Hours
Home

Informatica

INDEX
OracleDataTypes

Data WareHousing

Unix Shell Scripting

Contact Us
ORACLE INTERVIEW QUESTIONS

Monday,9May2011

OracleInterviewBasedQueries4

InterviewBasedQueries1

DivisionofSQL

InterviewBasedQueries2

Operators

151)Mybosshaschangedhismind.Nowhedoesn'twanttopaymorethan

InterviewBasedQueries3

GroupBy/OrderBy/
Having

10,000.sorevokethatsalaryconstraint.

InterviewBasedQueries4

SQL>altertableempmodifyconstraintchk_001enable

CHAT WITH ME

BuiltInFunctions
SetOperators

152)Addcolumncalledasmgrtoyouremptable

SubQueries

SQL>altertableempadd(mgrnumber(5))

Contraints
Joins
Views

TOTAL VISITS

153)Oh!Thiscolumnshouldberelatedtoempno.Giveacommandtoaddthis
constraint.

Sequences

SQL>ALTERTABLEEMPADDCONSTRAINTMGR_DEPTFOREIGNKEY(MGR)

Indexes

REFERENCESEMP(EMPNO)

Clusters

154)Adddeptnocolumntoyouremptable

Partition
ursor
Triggers
StoredProcedure
Functions
ExceptionalHandling
Loops
MaterializedView
SqlLoader
DataDictionaryQueries

SUBSCRIBE

SQL>altertableempadd(deptnonumber(5))
155)Thisdeptnocolumnshouldberelatedtodeptnocolumnofdepttable

Subscribeinareader

SQL>altertableempaddconstraintdept_001foreignkey(deptno)
5

referencedept(deptno)[deptnoshouldbeprimarykey]
156)Givethecommandtoaddtheconstraint.

FOLLOW BY EMAIL

SQL>altertable<table_name)addconstraint<constraint_name>

Emailaddress...

<constrainttype>

SHARING

PlanTable
Performancetuning

Submit

157)Createtablecalledasnewemp.Usingsinglecommandcreatethistableaswell
asgetdataintothistable(usecreatetableas)
SQL>createtablenewempasselect*fromemp
SQL>Createtablecalledasnewemp.Thistableshouldcontainonly
empno,ename,dname.
SQL>createtablenewempasselectempno,ename,dnamefromemp,deptwhere1=2
158)Deletetherowsofemployeeswhoareworkinginthecompanyformorethan2
years.
SQL>deletefromempwhere(sysdatehiredate)/365>2
159)Provideacommission(10%CommOfSal)toemployeeswhoarenotearning
anycommission.
SQL>selectsal*0.1fromempwherecommisnull
160)Ifanyemployeehascommissionhiscommissionshouldbeincrementedby 0
10%ofhissalary.
Share

SQL>updateempsetcomm=sal*.1wherecommisnotnull
161)Displayemployeenameanddepartmentnameforeachemployee.

StumbleUpon
Submit

SQL>selectempno,dnamefromemp,deptwhereemp.deptno=dept.deptno
162)Displayemployeenumber,nameandlocationofthedepartmentinwhichheis0
working.
SQL>selectempno,ename,loc,dnamefromemp,deptwhereemp.deptno=dept.deptnoGetthis
163)Displayename,dnameeveniftherearenoemployeesworkinginaparticular
department(useouterjoin).

http://naveenplsql.blogspot.in/2011/05/oracleinterviewbasedqueries4.html

1/3

3/14/2016

PLSQLin21Hours:OracleInterviewBasedQueries4
SQL>selectename,dnamefromemp,deptwhereemp.deptno=dept.deptno(+)
164)Displayemployeenameandhismanagername.
SQL>selectp.ename,e.enamefromempe,emppwheree.empno=p.mgr
165)Displaythedepartmentnameandtotalnumberofemployeesineach
department.
SQL>selectdname,count(ename)fromemp,deptwhereemp.deptno=dept.deptnogroupby
dname
166)Displaythedepartmentnamealongwithtotalsalaryineachdepartment.
SQL>selectdname,sum(sal)fromemp,deptwhereemp.deptno=dept.deptnogroupby
dname
167)Displayitemnameandtotalsalesamountforeachitem.
SQL>selectitemname,sum(amount)fromitemgroupbyitemname
168)WriteaQueryToDeleteTheRepeatedRowsfromemptable
SQL>Deletefromempwhererowidnotin(selectmin(rowid)fromempgroupbyename)
169)TODISPLAY5TO7ROWSFROMATABLE
SQL>selectenamefromempwhererowidin(selectrowidfromempwhererownum<=7
minusselectrowidfromempiwhererownum<5)
170)DISPLAYTOPNROWSFROMTABLE?
SQL>SELECT*FROM(SELECT*FROMEMPORDERBYENAMEDESC)WHERE
ROWNUM<10
171)DISPLAYTOP3SALARIESFROMEMP
SQL>SELECTSALFROM(SELECT*FROMEMPORDERBYSALDESC)WHERE
ROWNUM<4
172)DISPLAY9thFROMTHEEMPTABLE?
SQL>SELECTENAMEFROMEMPWHEREROWID=(SELECTROWIDFROMEMP
WHEREROWNUM<=10MINUSSELECTROWIDFROMEMPWHEREROWNUM<10)
173)selectsecondmaxsalaryfromemp
selectmax(sal)fromempwheresal<(selectmax(sal)fromemp)
PostedbyNaveenat13:10

Recommend this on Google

Nocomments:
PostaComment

Enteryourcomment...

Commentas:

Publish

GoogleAccount

Preview

http://naveenplsql.blogspot.in/2011/05/oracleinterviewbasedqueries4.html

2/3

3/14/2016

PLSQLin21Hours:OracleInterviewBasedQueries4
Linkstothispost
CreateaLink

http://naveenplsql.blogspot.in/2011/05/oracleinterviewbasedqueries4.html

3/3

Das könnte Ihnen auch gefallen