Graphic Fra
C
TERM WORK
on
DBMS LAB
(PCS-503)
2022-23
SUBMITTED BY: SUBMITTED TO:
NEHA KUMARI : MR. ABHISHEK JAIN
SECTION- ‘I’ Assistant Professor
UNIV. ROLL NO- 2018515 GEHU, Dehradun
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
GRAPHIC ERA HILL UNIVERSITY, DEHRADUNGraphic Era
INDEX
LAB-SHEET
[SNO. | EXPERIMENT DATE | PAGENO. | SIGN.
7. Lab Assignment. 1 12-09-22 | 914-02 |
| as Practical Lab Sheet- 1 26-09-22 03-09
r 3. Practical Lab Sheet- 2 | 26-09-22 49-12 : |
[4 Practical Lab Sheet- 3 | 03-10-22 | 49-94 |
5. “Practical Lab Sheet- 4 10-10-22 [ago |
6. Practical Lab Sheet- 5 14-11-22 [o9- 4a, |
7 Practical Lab Sheet-6 | 05-12-22 ] ug - ug - |
| 8 ~ Practical Lab Sheet- 7 19-12-22 | uq- 53
INDEX
THEORY
ASSIGNMENT | DATE | PAGE NO. | SIGN. |
i Theory Assignment-1 | 12-09-22 |S 4-59 |
[2 Theory Assignment- 2 | 26-09-22 | Go-62
3. Theory Assignment- 3 05-12-22 | ¢ 9- Gq | |
4. Theory Assignment- 4 19-12-22 | Fo-42 |=
Page No- Ol
anu @- Neha Kumasi
ection $— LT
pu No $— 32
udwet Td o- 20012698
DBMS Cab Assig
|
Dracle And Shen login
i} ussite Steps of Creating Now
into &.
Un sa) irstably , Wwe have to Opeh the Command Prorrpt..
Sperone ties
$n Oracles Shere ane some pre-defined Users such as
Svs. We have to Lagin Ovacle woth SYs ov system user
b) Shen » Verity Your User. Shen,
Ty pe Show User,
Than, for cyeakins
: wet. GQ Uner we have cho white given cmman
iN Command
Create User cease ddentified by abed3
4) Then, o Creating user WUL mot oboe -
ut ke Lae
dug one Przocos de on
7 es ko give Login And akher furmision to sthe
+ These Porras can only be given Parent
Uner, Peariasion U grarkedd by- Grant Cee ae
e) Then, again we can verity Our user by typing
Show User,
4) For atsiey tokles of thet User Wwe shype :
disc countries;
Whenever Wwe
displayed.
in 0 QA hew Uner no ctables ane_ fage No- 02
f dagin usthh Your new user ahd do the following —
[ha D) See Current User Nanos using Q di fe rent }Aothads
~ —p Dypes Show Unser
UseR is "C922T22"
Sype! Select User from Luots
USER
¢s2aT32
U) See Uat of tables Uaing different Methods
+) Methad 44 Select * from tab;
NO tows selected [| Since the stable is net defrree
JF Method 29 Select * fren Unerr_sbebles 3
4 Method 34 Scleok ¥ from cas
I) Select * from oll _userss
4 Displays aU Usernartes, their oer fe) and the
dake of Crection of thet Corer.
tv) Selock © from Uses tables 5
4 Displays “no sews gelacked4,
v) Deseribe TABS
y Displays stable gchoma or definition or colwnns
ov fieldsy
desevbe tabs
Nang Natt 2 ihe
Thee NOTNULL VAR cHARE 30)
clusreg TD VAR CHAR2. (tH
NUMBER
Vi) Desewbe CATS
Ditplays table scherna,
Vil) Describe User Tables $
Digtays Table Schama,DBMS Practical Lab Sheet - 1
Platform Oracle Express
|. Logon to Oracle by user name given to you.
». See list of tables by using "Tab / user_tables / cat" tables.
:. View the user name (Make sure it’s your user name: eg CSA23 etc)
|. View today's date.
Clear screen.
See the list of all environment variables.
Perform some mathematical operations by using dual. (Addition, multiplication etc.)
. Create a table “Student” with following attributes :
Field Name Type Size
Rollno Number
Name varchar2 10
City varchar2 10
. Display the structure of table
0. see the records of the table
4. Insert the following data into the table (As it is !! No Change)
Rolino [Name | City |
1 Amit - Dehradun
2 | Kapil | Meerut
3 | Dehradun
4 Amt |
5 [pen |
> Commit the data (Do not Forget)
. see the records of the table.
. add 2 new column named “Email", type varchar2(15)
‘4. see the records of the table.
'5. Display the structure of table
\6. Set the email of all records to btech@gmail.com
\7. see the records of the table.
18. roll back the email data
19. see the records of the table.
a
s
|. Display the structure of table21. Set the email of ‘Amit’ to ‘abc@xyz’
22. see the records of the table
23. Complete all the blank records of your own and add 5 More records (Total = 10).
24. commit data & clear the screen (clear screen)
25. see all records.
26. set linesize 20
27. again see all records. (note the display style)
28. see the structure of table (is it same as displayed in question no. 20? )
29. let linesize 500
30. again see all records.
31. set pagesize 7
32. again see all records.
. (note the display style)
. (note the display style)
33. set pagesize 200
34, again see all records.
35. set heading off
36. again see all records.
.. (note the display style)
. (note the display style)
37. set heading on
38. again see all records.
39. set pause on
40. again see all records. (
. (note the display style)
if not displayed , press enter , see records once more)
41, Remove the name column
42. Display the structure
43. See the records.
44, Make a duplicate copy of Stud
46, Truncate the “Student” table.
47. Rollback and see the records.
48. Drop the STUDENT table.
49. See the records of dropped table.
50. Rollback and again See the records of dropped table
51. See the list of all tables. ( Is your table present?)
fent table with the name “Duplicate”
52. Show user name
53. Disconnect.oT Pa 0
Name — Neha Kumasi age No O04
Section — TL
| ett No — 32
OGMs— Practical Lab She
At ype = Sqtplus
Enter Username ~ C929532
Enter Passiuerd —
Connected To- Oracle decabate
Jype- Sgly Show Wer;
User ib "eS a732",
4) SGLY select from tabs
TNAME TAgtyPe = CtustERED
SAMPLE TABLE a
SQL) Seheck* from Ler tables
TABLE NAME “TABLE SPACENAME CUUSTER— NAME
LOT — NAME) STATUS PCT-FREE — INT—TRANS een
SQL Yselek™ from Cats
TABLE —NAME TRALE TYPE
SAMPLE THRE
3} SQL) show wer}
User 4 Wegaat 2a”,
SPL > Select user from duaty
USER
C2913]
Gb SpLy soleck sysdede from duty
SYSDATE
19-Sep-ag—
Ss) SPLY Clear serean ,
GS} SOLY Showalt.
Appinfo ts OFF and sek to"SgL* plas!
Orraysixe 1S
Ousko commek OFF
tuto Pairk OFFPage No-02
Yp SGL> seact 18 from dusals
M8 |
SC
SOL dselact 843 from dural;
a4
Spt } select 81-46 from ducts
89-70
oe
SOLY Select 48/2 from duck
8} Spt} create table student (Rotine , Name y Varchar2 (10), City Vereter2(19)
Table Created ,
% SEL} dese Student
Nope Nut? Type
RouNo Nomaer,
NAME VARCHAR2 C10)
city VARCHAR? Cts)
Woh SQL> Select *from shudent;
NO HOWA Selecked
WL SgLyinserk into studet values (Uy tAmit}! Sctmadue')*
Lov created
SQLY insert into Student vetues (ittoptt, Meerut’):
4 rots Created,
SOL) insent into stuclert Values (8, nub tDebvodvert);
Aros creoted .
SOL) insert indo shident yalucs (4, HAmit!, nth):
1 sow Created,
SOL) insenk tro Stdert values (6) nubs (dethi!)s
1 stow cwreaked,
12} SQL) seteck* from Ktuart}
ROUNo NAME cxrty
oa Amie oo “Dehraden
3 vote Derodian
4 Remit.Page No. 03
PIapSGCY Alles fable studuct adel (Email Vardar2(15));
Table Created. .
ty) gt} select & from dbaddent ;
foun KAME CITY EMAIL
3 mtd: Dehradun
5 Oebhi
ts) SGLPAae Seadarcts
Nowe Nu “type
ROU No “NUMBER
NeMe VARCHARD (10)
culty VARCHAR (10)
: cele VARCHAR 1S)
SQL) update sbudsrct set email = Uy @ grail. cor;
Be Updated. tech, Coxe! 5
1) SQLS Select® from students
RouNo NAME city EMAIL
2 AW” Serafin bich@ grail can
3 Kopi Haart beck, @ grail. com
4 Prat Berrodun bixchDgmoil. com
5 eth btach@ grnail. Com
13) SOL atoaltbase; aaa
Q 3
RoUiback Corptaked ,
19) SqLy Select trom sticledts
I1 Record 18 garne as in (t4
20) Sroucture of dhe table Ls same as ines),
AU) SUL) update sbuclert sot emule
2 nows updobed,
§) Brat coburn sor bob the utd! ty updated Bo late @ eye's
23) SPLY inser Into ghclont values (6,Mogesh! IKhastire!, "Yb Oginetl cal
[This Query is used ao U thes more ato ockol 10 second,
au) SQL) Corot 5
Commit Comeleted .
SALy clear screen,
‘abe@ tyyz! thane Names! Aact!s
QS) pd tO swoords are disflayed an the doreen,Page No. 04
abe @xyz
iy Similarly Other 4 reeorlés ane dinflayed,
28) Struchure 1s same but tts dis flared Less Wider 08 corepared cto tt
oreoutk (¢hrucsure ) disglayed in ques. mo.Q0,
| 29) SOL} sk Unesixe S00.
| Pe) Records ane dinflayed try the seme Style as Ub Utd in qycction 26,
RouNo NAME ciTy EMAIL
i fd Gebeetin ab
to
34) SGLY sek fogesize Z
2) SOL) seleck* from sheers
RUNS Meme tery ENA.
4 Arai “Dabrodin ake Ouys
2 Wop Meorut gue
i Shuthom Osnodun ate @ raya
Frnt Khotire. abc @
ROLEN NAME woe
| : cITy Email
| [Y Sirnidanty Column nomes ang Atpeotad ott [irking Y Arcorcd,
33) SOL sek fagesine 200.
| 34) A FeCords Ody displayed adetegethey Uidchoust Aapettthion of colony
| Nome,
| 35) S@L} set heading off
RC) a Ant Debpodtin abe @ny2
: WHesalings are not dioflayal,
do
34) SOL} sek heading on,Page No. 0S
Fo)
Rone NAME CITY EMAIL 7
Dehradun abe Ores. :
oS . UHuecdings ane dinpleyed 292%,
spl ft mat a te fn hr tg
Yo) sgt y Select® sa unt
I Nothing 4 dus iy
tr frets quar, .
UTable & dinflayed agsin,
WA) SAL albew table Shelent drop column pare;
ea) Made co
“ROLLNe NUNBER
ary UARCHAR2 (1d)
Email VARCHAR (to)
M3) RolLnle city _ eral
1 Debrodun ake @xyo
Q HMesrrust, Abe @xyo.
to
A rows elected.
UU) SQL> create table duplicate os sobeck™ from stucberds
46) SQL} trunceke table steclonks
YE) ROLY RolLbook 5
| RalLback complete
SOL heck from Stxlerts
No nous 7
|43) SLY drep table sheclerds
YA) SOL) elack® from sbeclarces
Slack ® from Aachen
ERROR af Uneds
ORA- 00942! tale on ulerrdoeunat erdat,
S0) Aftyy oolsath table 1s not kecourred ane the cuectpst Ly Somne
a8 In C49),
4) SQL) Select *frm tabs
TTNAME TABTYPE CUSTER ID
ouPlicaTe (BO ga :
eaMare ee H Staclart table to nak proet,
42) SQL} Show Wer n
. hse |
USER Us Yesaat 29%,
S52) Sq@LYPSconNEcT,DBMS Practical List - 2
Platform : Oracle
Logon to Oracle by user name given to you.
See list of tables by using “Tab”
View the user name, make sure it's your login name.
Create a new table “Employee” with following attributes/fields :
Field Name Data Type Size of column
EmpCode Number
Name varchar2 6 (Six)
Salary Number
. Display the structure of table
. See the records of the table
. Insert the following data into the table using any method:
EmpCode | Name Salary
101 | Amit —_| 30000
201 Kapil 22000
301 Rohit 45000
401 Amit 27000
401 Amit | 27000
Commit the data (Do not Forget)
4. See the records of the table.
). Try to Add the following new record
10. See the structure of table and note the size of name column
11. Increase the size of name column to 25.
12, See the structure of table again
13. See the records of table.
14, Now again try to add the above record again,
115. See the records of the table
16. Reduce the size of name column to 5. (Note the output even if it is an error)
17. Commit the data and see all records.8, Execute the following SQL queries and note the result:
a) Select name from employee.
b) Select name, name, name, name from employee.
¢) Select name, empcode from employee order by salary.
) Select name, Salary, salary + 500 , salary-50000 from employee.
e) Select sum(salary) from employee;
f) Select min(salary) from employee;
g) Select max(salary) from employee;
19. Display name, actual salary, 50 % increased salary of all employees.
20. Make a copy of employee table as “NewEmp" table with all records.
24. See the records of “NewEmp’” table.
22. Make a copy of employee table as “Emp2"” table with no (Zero) records.
23, See the records of all 3 table (Employee, NewEmp and Emp2).
24, See the structure of all 3 table (Employee, NewEmp and Emp2).
25, Create a new table “MyTable” from employee table with only Name and Salary columns.
26. See the records of Employee Table and MyTable.
17. See the list of all tables.
’8. Commit your data.
19. Drop the columns “name” and “empcode" from NewEmp table.
40. See the records of NewEmp Table.
M1. Truncate the “Mytable” table. (do not use delete command).
52. See the records of “MyTable” table.
53. Rollback.
. Again See the records of “MyTable” table. (What is your observation?)
45. Drop the “MyTable" table.
46. See the records of “MyTable” table.
47. Rollback.
. Again See the records of "MyTable” table. (What is your observation?)
$9. See the list of all tables in our login.
40. Commit the data.___ Page a
pName- eha Kumayi
Sechion - I
Ratl Now -32
Dams Pyackicat Lele Sheet -2.9
4) Spe Saiptut .
Enter Usernank ~ CSQ2T3Q
Ender Password ~
Connected Jo- Oracke dotabase.
SJype- SPL} show Users,
User (S$ "esoatag"!
8) SQLS Select® from tabs
| TNAME TABTYPE = cLUsTERTD
CENUSe Say Et eee
3) SPL} show Users
User ig "el 297 2Q"
SPL) Select Uses-from dual *
USER >
Cs29739
YY SQL} Create table Employee (mpcode Nurnber, Narne Vereraa(é
Salony Nuunter);
Tobe Created.
| Sk SOL} dese Employees
| Nowe Nutt? Tyee
Po eee ene PE
oa Nurmbey
Vorrchary2 (6)
Salosyy
Gh SOLY selack* from Employer;
NO Hows selected,
4) SQL} insert into eyrployee Values (101, tAnik!, 80000);
created
1 Know .
Sty ee into Employee Voluet (201, apt, 22000)
you meadked ,
SLY trent into Employer Values (301, rRanie!,
46000)
A now created,
SGLY fruent into Ernployer VoLued (40), Arait!, 23000);
Aro cwveoted , \ ' »s
SELP insert into Ereproyer Volues (Yo), (Amit), @oce)
1 oro Creded ,Page No.0
8) SQLY Select *-from Employers
ErapCede — Narre Sotany
“tor : Aik 30000
ea Kop 2.000
ea Roki Ysooo
dot Auait #000
Aut #000
4) SPLY insenk Thko ern
Ave values cont on (201,16 hattachango! ,22006)$
U Since, Size of narte column fa ;
'e) S@LY dese at Enuployer ¢
Noite
aoe Noe “Type
Entptade = Wis a.
Solana Vanrcharr 2(6)
LU Stee Of naKe column, ce Murs ber
W SQLS aber table Linployee nriodi
12) SQL} alese Crployect ogeh iy (Name Varchar2 (259):
Nokee
| Emplode a eres
Salan Verrchar2 (28)
Number
18) SOL ysuleck ® from Grpioyees
_ fn aoe Nowe Selany
{ol cst cocoa
Sa Kopi 22000
Robi: 4s 000
° «
Yo! Aucit 2H.0.00
Aust 234000
POLS cece d , Employer Values ( oI, ' Gheettachanya!, 33000;
'S) SoU} select # rom Lonployes}
| Empcode No J
J
ra Auch "30000 —_
a) kop 22000
40) Remit 46000
Yo) Ark, Q¥ooo
oe) Aut Qto00Page No. 03 |
16). Spt} alter table Sp layee stadity (Nome Verena);
LU] Since, peoordr have values of size Ktore Bran S,
ERROR wih ocr.
WW) SLY Commit
Conc Conipteted ,
SGLY Selsck * from Lmployecs
Eniptode Natee Salangy
“101 Rue BoG0o
Rol Kap 2Q000
ol Robie YSooo
Yol fut, A4t000
Yol Prue 24000
Aol Bhodtruharya 33000
© Nows selecked,
18) a) select pone Prom Employee}
Nowe
Aucé
kop
Rohit
Aude,
Audit
Bhattacharya
G mows selecked
b) Select AML, hae, hame from Employees
— Nowe e None Mone
Anti aati Rae
Ropu hap Ropth
Rohit Robi Rabi
Prk Aut Ant,
Ausce Amit Ande
Bhodttacharya, Brostacharya, Bhoskkrchansja.
arnpcode from employee orcer by salany;
&rn
Nowe
Kapil gol
ars Yo}
Frat 4ol
Anh Lol
Bhocteichasyta Ao!
Rohit, 30}
:Page No. 04
d) Select nate, galany , Solany +500, Salary 50000 from employee;
None So.Lany +500 Soloyy—S 0000
aunts 7] Ro000 ~~ "Bosco 7 —20000
Kap ul 22.000 2aS00 —2$o0e
Rohit ysooo UsEOO —5000
Aut Q300° QAS0e — 23000
Ant 2z#O0e ASO - 23900
Bhatia chayya 33000 33500 —l4000
€) Selack Sum (Salas) fron employes;
Sum Salory)
1 4ooo
F) geleck win (salary) rom employee]
Hin (Salary) .
~ 22.000,
§) Select Haw (salany] from employee!
Max (Salsng) a
Ysoao,
14) Seleck name, salary, (So% Salary |
! loo trem emp leyze}
Nowe ra _Saloy Lossy (So* Salony/) [too
fh ge Isso
Robik 4S d00 eS
Anit 2Q¥#000 22 $00
Panik Atooo none
2 12500
Chea 33000 ena
20) Create +
Table Creates re OA Seleak# from Simplayer;
31) Select trons Naso emp}
--4oe Satan
26l Aud “goses”
Bol Kap. 22000
Yo! Rronit U6 000
Uo} Prvsick Ato 0
Ao} And 24000
Bhotlachagya 33000
C rou Selected,4-27
Table Created,
23) Select & fron employers
Empcooke Nome Salasyy
tol Awl Boca
Qol Kop 2200
30] Rohus 4YBO0o
Yol Awak QHOOO
Yo! Ancck aAXooo
dot Bhottachapye, 53000
6 vows selecked ,
Selock * tom Nevo mp}
Emprode — Nomee
10} Aud 30000
aol Leopth 22000
201 Rohit 4So000
Yol Pale aa
as fruit p00
Grou sey peters 38000
Snptede Mowe ” Solan
Ae eh -— |
2) SLY dere Employer}
es ee ete afc
oa: Number
Varchor 2 (aS)
d Ham ker
SOL} dese ters Emp,
—— Nash Type
gl "Naber
Nosse Vinchar3{28)
Salas Numter
SHLY dese emp 2;
ee ite
Emptode Number
Nowe Vowrchar 2.(25'
Saloovy Nuwunker.
Page No. J
[aa Creake tobe Emp2 Ge Select® from employee whersPage No- 06 | |
Qs) SLY create Mybable as golack Nari, Satay From employer
Fable Created.
26) Selock * Employee ;
Eng Poste Soa
“Tor Awake 30000
Qol Kop 2Q000
Bol Rohit 4gd00
Yol Antk 2H
Yo! Autt Qeto0e
Yot
Bhosttacharya 33000
Select * from Mytabhe f
be Nae Salone
~Anik ~~ Be000
Rap 22.000
| Rohict 4sa0o
| Arch tooo
Ask Q4tooo
Bh 33000
24) SYLY seleck # tabs
JTNAME __ _TTABTYPE_ Custer ip
EMPLOYEE TABLE oO
NEWEMP TReLe
Emp
MY TABLE a
28) SYLY Commits
Commek Completed . /
24%) S@Ly alter table New®np drop column nante, empcode;
30) SoLY select ¥ torn Neen;
| 33000
31) SOL truncase -bable Muptabhe 5
33) SL) Select * fran My table;
| nO HOWS Selected ,Sa) Spey owls
Rollback, Completed .
3Y) SpL}-sele t® from Maytables
No sxows Selected,
35) SQL} drop cable Maytables
36) ye aa from Mytakle;
* mA Myptable;
ERROR at Line 2:
GRA 00942 :-table on Utety dovonat evirt.
34) So} srollbacks
Rollback Corpleted ,
38) seloct # from Mytables
Joble on View doesnot extak.
39) Setock & from Tabs
THAME TART YPE- cwsTe RI
‘DUPLICATE c= oO
Em 2 TABLE
EMPLOYEE TABLE,
PeLa£mP TABLE
Yo) SOL } Commits
Commit Corrpleted ,Practical List 3 - (Like Where Etc)
Subject : DBMS LAB
Logon to Oracle using your User Name
See list of tables.
View the user name from dual.
Create a table "Students" with following attributes :
Roll No Number 8
Name varchar 15
City varchar 12
Pincode varchar 8
Age Number 2
Display the structure of table
Insert the following data into the “Students” table (Enter as itis, take care of Null)
RollNo |Name | City Pincode| Age |
[4 [Amit | Dethi 214213] 21 |
2 | Kumar | Bombay 25
3 | Kshitj | Madras 10101] 16
| 4 | Puneet | Caloutta 18
5 | Rohit | Delhi 502207| 19
6 Kamal | Dehradun 28
7 | Shweta | Dehradun 98102) 23
8 | Monit | Bombay y2aga| 22
9 | Pankaj | Bombay 17
10 | Parul | dELhi 76312| 24
11 | Rohit | Baroda 42131| 28
Write queries for the following outputs.
> Show all records
> Show names of all students living in Delhi.
> Show record of all student whose name starts with
> Show record of all student whose second alphabet of name is “a’.
> Show record of all student whose name ends with “it”.
» Show record of all student whose name contains 't’.
> Show record of all student whose name contains ‘t” but not in end.
> Show records of all students having age greater than 25 & living in Dehradun.
» Show the list of all cities (names of cities should not be repeated)
» Show the names students alphabetically in ascending order
» Show the records of those students which are either less than 20 year or they are living in
Bombay.‘Show records of all those student who are not living in Dehradun.
Display all names in uppercase.
Display all cities in lowercase.
Display name in lowercase, cities in uppercase.
‘Show all records in uppercase
> Display those records which do not have pin code.
Insert the following data further into the same table.
MZ 7 A we
Roll No | Name City Pincode | Age
M2 | Gaurav | Rampur 312125 |
Manish 314136.
14 Aviral 319143, 29 |
115 Gwaliar 313149 25 |
Write queries for the following :-
() Assign Roll No. “13° to Manish.
(i) Assign the name “Abhijeet” to Roll No. 15
(ii) Set the cities of Roll No. 13 & 14 to “Meerut”
(iv) Increase all age by 3 years.
(v) Set the age of all students living in Meerut to "25".
|. Add a new column named “Balance”, type number to the Students table.
. Set the balance of all students to Rs. 20,000/-. See All records. Commit.
Increase the balance by Rs. 500/- for all Bombay & Delhi students. See All records. Commit.
. Show the total balance amount of all students.
. Show the maximum balance.
. Increase the size of "balance" column to 10.
. Reduce the size of city to "10"
. Create a new table “student2" as a copy of Students with all rows from Students table.
. Show the records & structure of student2 table,
. Delete the records of those students from “student2” table who are greater or equal to 25 years.
. Show all records of student? table.
- Change the name of student2 to “Newstudent”
. Delete all records from “Newstudent” using truncate. Do not use delete.
22(a) See the records of "Newstudent” .
22(b) Rollback and see records again.
. Drop the “Newstudent” table.
- Again create the “Newstudent’ table similar to Students table but this time without any records
py only the structure. See the records and structure of ‘Newstudent” table.
. Create a new table named “MCA with only three columns RollNo, Name & balance from
tudents” table along with its data. See the records and structure of “MCA" table.pe Paige Noe ot.
Nawe — Neha Kumasi
Section - I (4
Rott Noe - 32 : A
| Ghudent Jel 20012698 a
DOMS Cob Jestgrntiot
4) Conn
Ugernamees CLAIT3BQ
Password § Oba,
2) saleck* from stots
ee eeuice Cuusiehes
DUPUTCATE TReeo!tt”t”t”*~CS~S
Emp 2 TARE
en PUYRE TARE
NEw @MP there
3) Sek user from duals
USER,
(829532
G)SQLY cveote Lable students (rott no. number
. (6), name yarchor:
OS), CHa vorchar 2 Ula), Pincade Varchar 2 a}, age nemss
(a))s
“Toole tneocked ,
S) BLY dant studuness
Nawe Noll? TY pe
oe ee)
No.
ese Vaowelrow 2. 1S)
Ck Vorchar 2 Ca)
ia cede Vowchay2 (8)
Age Number (2)
©) SPL> Snaent futo Shucerts yates C1, uct!) Jetty /)'21a1
2);
A tow crecced ,
SQL> Ingerd ino chiclink elucs 2) | Kamar! | Bortoy! Nes
2s)5
ZL rots cveobed
: a yc 14
BLY Inserk Jute studset values (3) Hugh 4 Madras! Hote
16);
A youu crected |7 : Bee
a Yhserkt Trto stuclond vatues (4, 'Puncet!, "Caleta! Mull,
;
A row Cvecked ,
ate Freent Tuto Seclorck valut (6, 'arnoat!, Dehrodun! Mutt,
;
A you cweated,
SQLS Fngenk tbe bw jou
i dunk values (4) Shekel, 'ehracd un! |4e109
Arve Cvecded ,
SOLY Gnsenk § :
ays ne Mtudeect values (2, 'Mabit!, "Bornbay’,! 124 94',22)
ae 4ngerk whe Shudpt valued (4, 'Pankes') Bombay’, Mul! |=
yes erected,
SOL t
te onset Into Studer values (10, Pond (Jeuhi!, !46312126
: reoked| '
an ldo Shuderc Yoticer (M1, (RaLE!, 'Boreda’, 112131
)
4 yous creashed,
+) SqLy Selock * franc Qtudentes
Rowe NAHE CLTY —PINCODE AGE
a Aye Debbi 4S
a Rurror Bombay as
= Kshasy Madras 110101 1G
4 Puneet Cohen 18
5 Roce deh §02a04F 19
G Ronnot dehvadun ag
4 Shweta cldvadun FWlOAe- AB.
& Hone Bombay ta4y34y 22
4 tantee$ Romboy 4
10 Porukh ddWi FAE3IQ AY
if} Rorik Roreda 1213} Ad
SQey Select nome from Students tohare cot = # gett;
NAME
Ano
Rack
SOL} Selak* frre Studurta Lohere narie Auea ALS
ROLL NO Nene atTy PINcoDE AGE
a Keck Bali Sotuaie al |— Page No-+03
SPLY Select * from Students cohire norte Live tarts
wie |
Row NO MAME CIty PINCODk
a AGE
~~ ¢ \Carmmot "benvedun, .
9 Panes Romboy \4
\o Part Delhi 46312 ay
SQLy Sek» from sided here neue OMe Cees
Rou No Name <7 PiInicoDe Age
oy hee Deb aus ay
S Rola Doh Sea2ct 44
z Mohit Bornes 12434 22
at Rowit Qorodo NSN al .
Spry Seleck* {rom Studurts cshare Nave Use E15
Rort NO wAtae awry PIncooe = AGE
a TA gal a )0hUhTL
= Leh Hadras \\ oto} (2
4 Puneak cohen \8
5 Rott ‘ soxac4 a
2 Qhusek dehrodun 43 1oa a
s pole Goriny va.43u 22
a4 Rote Bard 1ai3l a4
SLY Qelack # fron gtuslerte Cohare nave Ulex Ye bye!s
Rou No _ NPE City Pinicone Age
3 WeneG | Pedene ONO a
+ Khuweker Derodun 4atca
BOL> Seleck® from Gales Lohere age 725 Wd
clip = Vaekoedun! 5
Rauwo Name erry Fins AGE
G Konret — Delrradun i: “nae
SQLY Selack eliskinct ey fren stodents$
city
Dehredury
Borntoary
Hodvas
Colermstha
Dani
Rorredo.
SQLY Setock pame frem Studer Orcler by U5
Name :
Pek
Korn .
Ksh ti?Kaman
Mott
farntery
Paral
Puneot
Role
Shwete.
SPL Selec ¥ from shadends usheve ag? = 20 os ty =
"Bombay! 5
RowNo NAHE ality PINCeDE late
a Iaurnet Bormaay oe :
3 Kaley Madras 11010} 16
au Puncot Cobcudtha \3
Rohit Dei 502204 19
@ :
4 ead Cones 12434 a2
< a J Borns at
QLY Select ® fyomn Students where La! Debwodurl
Roune NOME erry PiNeooe” AGE
a Auk pes ols) ae
2 Ranor Bornbay
Bsheby padeas Alo ol
4 Purees Codenstto
. -
; Rohit Delhi Soaaoy
+
8 Mobt Bombay 12434
4 Panto} Corrbsy
° Porat Debh? +
2 6312
Sal} Sone water tnnd feo Anal
UPPER Caines) frend Fron oes
Ata
Rumer
KSA ITT
PUBEET
Routt
KARNAL
SHueTA
HoH IT
PANLET
PARUL
RoHLT.— —~ a Faye No- 05
sory Seloct lower Coty) from Sherclent>}
Lowe Certy)
: duunt
madras
benrbay
cobcutt=
dou
clahredun
dehredun
bombay
Bornbe'}
daly
honed a F
SPLY seheck Loser (naree), UPPER COTY) fram stoctads }
ae LoweR CNerey) ; VPLER Carty) PINceoe = AGE
0 ee Fe ays
SOL) Selec UPPER (NAMB), UFPER (CITY) From shufoxtss
RoLtLNo —-UPPERCNAME) UPPER (CITY) —PINCore AGE
[ AMIT DEW} oa al
qty select * from Stulerds cohere 2LINCoDe = NULLS
RoLLNo NAME |
CITY PIN@ae AGE
2 Kurméc Gombay as
8) SPL} Insert fnto Students Ualues 12
NULL),
Gaurav, Rampur, 1312125
i Aen Into Studerds Valois (wun, 'Mantun!, NULLS
ULL
SOLS Inserd firto Studards Values Qu, Avi ray, Nucl, ‘319
Q b
SOLY Ingen Into Cleelenk values (6)! NULL WG wetioy!, '3149
Qs),
9) i) Updlocke. Stuctents sok poll now=43 tahoe nous Man tants
roy updeded ,
U) Updoke ah An
i et . Sek Notre = Athijeat! Lohore ral no = ls!
Ti) Updote studlenes 4
ae : arian : a = ' Meerut! rdere molt nom 123
Q Nous Updeled .
ty 2 Meerut! dere Yell hos 57 — Page Mo 06
iu) Update stucomts Sel age = oge+3;
AS Nos Updater,
v) Updode ghudents Sek Oge= AS where chy = "Mearua!s
Qrovas Updoked ,
lo) SOL} alter table Students add (Rolanae numberds
Tate attered ,
u) updote Shudents set balances 20000;
LG yous Updated
gelack# from Studerts5
Commits
12) Updacke. stufends sek balan < balance +$00 there
chhy = ‘Born boss's '
Updote Studends set balance = balance +500 Lohere CAN
<=! Delhi's
(3) Seleck stom (balance) from studerd ;
Sum (BaAance)
202800
14) Solace mar Lbataney from students
MAX (BALANCE)
~~ 30500.
1S) Updete tale students todity (Balance numicr(loy);
Tale Otkrred ,
Pret steele ty 3):
vet) Cireoke choke SreHkQ OL Sele ck¥ from stuclorcts 5
“Table Created ,
18) Selot# from Stuctant 2s
ROLLNo NAME city FINcope AGE BaAcance
4 Ance Delhi Aluais 24 Qos0o
Cc
dese Stucord 24
Nowe Nuu? Type
Row No : 'NUMeER (2)19) delete from StuclarkQ cLohere age -= aS
Grows deleted,
Qo) gelect® from Shuclent 25
Rot No NAME aity PINCOPE = AGE a
4 Duke Deh 21ua12 24 2000
fage No. OF |
'
e
Grouss selected,
21) Alter tele gkerlords pena to Meus Studer;
Tate Created,
20) “Truncate teble novo Student}
Tab +truncccke .
a) Sele ck® from haces Slee;
ho yews Selected,
8) Rolibacle
Soleck® from nerochuclarch;
ho rouss Selected ,
23) drep table noisteelyrks
Tatole drepped.
uy Creode keble now Stodarct a9 geleck*® from st
whe Le 25
“Tobie Unoaked,
Seleck & fram nats Short;
ho rouss Selected,
dene nots Steelerd $
Nowe Lu? Type
RoLLNo ‘Nuragels)
QS) Creake chakle McA as Selosk valino, hart, belance for
Stoctonsa’,
“Tobe Created .
Sere ok * from Mans
Ao No NBME BO LANE
+ Arcee 20560
dec KCAS,
Mahe hu? Tye
Rune BRUMBERG)
Ss)Practical List 4 (Applying Constraints)
Subject : DBMS LAB
ogon to Oracle using your User Name and check your user name.
ee list of all tables.
‘reate a table "Car" with following attributes :
(Assume Data Type and size of column of your own, they must be relevant)
Display the structure of table
-opulate the table with all the car models of “Maruti Suzuki’ , “Hundai" , “Honda” ete companies.
ModelNo
ModelName
Company
EngineCapacity
Color
Doors
Weight
TopSpeed
RPM
CostPrice
SalePrice
Primary Key
Unique
Not null
> 1000
ae
> 1000
< 500
>5000
( Please Fill Proper and Relevant Values for Each Tuple)
WWrite queries for the following outputs.
Vv
vv
v
Show all records
Show names of all the cars of Maruti.
Show record of all Cars whose engine is more than 2000 CC.
Show record of all cars of white color. .
Show records of all vehicles which are costing moré than 4 Lacs.
Show the costprice, saleprice and profit on all cars.
Show the names of all cars alphabetically.Now create another table named “vehicle” from “car” table created in Q No.3 without records,
wever the columns should be in following order: ( Do not write the complete new create table
tement, rather create table from existing Car Table without records).
o not copy any records from Car Table , Copy only columns)
e Column should be in following order only:
TopSpeed
Doors
CostPrice
ModelName
Company
RPM
EngineCapacity
Color
ModelNo
Weight
SalePrice
Display the structure of new table
Now Populate the “Vehicle” table with all the records of “Car” table but the records should be
serted in random order this time ( Not in same order as of “Car” Table).
(Like 11,4,5,1,7,3,2,9" record etc)
o not write new Insert queries, rather copy records from “Car” table in
andom order.
Re-Write queries given in Q6 on “Vehicle” table and notice the output (Is there any difference?)
> Show all records
Show names of all the cars of Maruti.
» Show record of all Cars whose engine is more than 2000 CC.
Show record of all cars whose color id white.
Show records of all vehicles which are costing more than 4 Lacs.
» Show the costprice, saleprice and profit on all cars.
» Show the names of all cars alphabetically.Page Noe od
Name - Neha Kuntox?
Seckton- I
Rolt No. - 32
Student td - 20012693
DEMS Lab Asstgrrment- O47
_ DBMS Lab AssijrmentT
4) SQL>conn
Crctor User -— C8227 32
Erdey Passwort - abed
Connected ,
SqL> Showuser
User ts 'C$.29139',
8) SPL) Selact* from tabs
ho ows Selacked,
3) SPL) Create tobe CMedol No lumber Primany Kerf, Model lone
Varchar Ue) Unigyre, Com and Varehar Cle) Nek Nuth, Engine Copacs
Number CHECK (Engine Capac
1009), Color varchar (+), doo
Number CHECk (Door yd), Weight Number CHE ck (Weight +1009),
epspeed ¢
Number CHEK PriceKhember (Topspeod S00) RPM Wumte
CHECK LRFM >Soo0), vee i
s) SLY Insert tro cor Vadweg
WO (280, 5010, 46000, 30000)
SPLy tnsert tno cor Yatuies
M100, 10, $419) {{o000
SOL lmaenk tro cay Gotues
QW 1S 00,140, 5050, 4S 000, (200.
Cook Price Number, Sate Price N 5
ae ee : Yee Number) 5
4) SLY dase cary
One Nut?
ae epee pe.
Medel No Nok Null Number
Model Nanre Varchar (to)
Company Vewrchar (0)
Rrgine Capac Mok Neth umber
Vowrchoer( })
ee Number
nk. Number
Top Speed Number
Re Number
Cort Prvee ‘Number
Soke Price Number
(210, 'sutfet, Moxuti! (200,' Black’, 4
(at, tettay, Horlot, (00, Grey's 4,
114 e000) $
(Ria, MThar!, (Mahindra! 4820 ,! aad
So); : :Page No. 02
Select * from deat;
Sreux selected,
G) A) SQLY Selock F from cars
Modal No Model Narre Company Engine Cope dty Color
Doors Weight Topspead RP emt frca Soto Pree
210 'sutpe! Maruti 1200 Block
4 loo Qs50 Sovo Yoo00 Fooso
.
b) SPL} Seleck Maocel nade from Car whee Company = "Wonks!
HopEL NAME
: sash kl
ASGrdy Seleck* from cor coheve engine copacktsy + 20005
dy SOL} Select * from Car where Color = !nohite’s
g ROLY sebook * trem car where cook pricephOoo oo;
HSQL Sclack Cook Pricey sale pricey Sale Pree — cook Price as prot
trom Cory,
ost Paice Sote fries foro pt
4 0000 “B0000_ - 40000.
llo000 140000 30000
48000 120000 2£000
8) SLY Seleck modetname from car Ord yr by Hadel Nayes
HROLY Creoke table vehicle as seleck Tepspeed , Doors, Cost Potee,
Modul Nowe, Company, RP, Engine Copa, Color, Hadel Me,
Comspoure
Lueight , Sotelrice Prom cars
Toble Created,
SQLY dese velidt,
Nave Nol? & 1 ;
“Top Spee Nlunber
doors Nurnkey
Coste Pree Number
Haodel Wane Varco ito)
Wot Nott Varchar Uo)fage No. 03 _
RPM Number
Engine Copacily Number
ColoY Yarchor CY
Model Mo Wok Mutt Numbe7
qwetglt unter
Fale Price umber
4) SgLY Inseat inko vebiclt select TopKeed , Joon, Coot trex, Wade
Nauc, Company y RPM, Brgine Copacdry, Color, beoefgh ‘Namee
weight, sale Pre from Cor Order “by dsms rand on ili
Lohyspe y Sele” from velricle;
BH SOL} Geleck Hodslnotte from velaiele wales Company < 'Man
Modal Nant
dusfe
9g Sele ck from velricle Lwhere engine copaddy }2.0005
A ge k® from Velicle where calor 2 bwtuke!s
2 Select * drem velricle here cork Pree = 4000005
Gf) Salek Model nanee from veliicle order by Hodal nate?lease do the Sheet patiently as it will take some time.
DBMS LAB SHEET - 5
Platform : Oracle DB
Basic SQL Functions
PART - A ( First Do This Part)
RUN THESE QUERIES IN YOUR SYSTEM. ( You can copy and Paste, But sometimes
copy paste gives error because of quotes issue)
_ )WRITE OUTPUT OF EACH QUERY ON A4 SHEET ALONG WITH QUESTION/QUERY
IN CASE OF ANY ERROR, SEARCH THE SYNTAX and CORRECT THE QUERY.
QL> select upper('gehu') from dual;
QL> select lower('GEHU') from dual;
QL> select ‘hello world to all' from dual; Note the output and difference carefully.
‘QL> select initcap(‘hello world to all’) from dual;
QL> select’ hai’ from dual;
QL> select Itrim(' hai’) from dual; Note the output and difference carefully.
SQL> select rtrim('hai ') from dual;
QL select ‘hai ' from dual; Note the output and difference carefully.
QL> select rtrim(' hai') from dual; Note the output and difference carefully.
QL> select concat(‘GEHU',' university’) from dual;
> select length('GEHU’) from dual;
Q.> select replace('GEHU university’, 'GEHU,'GEU’) from dual;
QL> select substr('UNIVERSITY', 4,6) from dual;
SOL select rpad('GEHU',10,"*"}from dual;
SQL> select Ipad('GEHU',10,'*') from dual;SQL> celect Instr('COCOON',’0') from dual;
3QL> select replace('Dany','y',"ie') from dual;
5QL> select translate('cold’,'Id’,'ol') from dual;
SQL> select sysdate from dual;
SQL> select round(sysdate)from dual;
SQL> select add_months(sysdate,3)from dual;
sal> select last_day(sysdate)from dual;
sal> select sysdate+20 from dual;
3QL> select next_day(sysdate,'tuesday')from dual;
NUMERIC FUNCTIONS:
SQL> select round(15.6789)from dual;
SQL> select ceil(23.20)from dual;
SQL> select floor(34.56)from dual;
SQL> select trunc(15.56743)from dual;
SQL> éelect sign(-345)from dual;
SQL> select abs(-70}from dual;
MATH FUNCTIONS:
SQL> select abs(45) from dual;
SQL> select power(10,12) from dual;
SQL> select mod(11,5) from dual;
SQL> select exp(10) from dual;
SQL> select sqrt(225) from dual;
(PTO)LAB Sheet —5: PART -B
agTER RUNNING ABOVE QUERIES NOW ANSWER THESE QUESTIONS ON Ad SHEETS:
at what are Single Row and Multiple Row Functions in Oracle SQL. Explain in detail.
a2. Prepare a detailed list and notes on Following Type of Functions:
Various types of Character Functions
Various types of Number Functions.
Various types of Date Functions
Various types of Conversions Functions
Various types of General Functions
NVL With example
~ NVL2 With example
CASE With example - Important
DECODE With example - Important
sing each Type of function, write your own SQL example along with output which
executed in your System/Laptop etc.[ Nan — Nebo Kumoxtt
Seckion — I
Rott No. -32
Student Id - 200126938
iP dans Zab Agi
3S QL> Setock Upper (gehu') From dots
UPPER
Genu
9 SQuy Select lower (’Genu!) From ducks
LowER
gehu
4 SQL} Select 'heblo world to at! from ducks
‘HELLS URLOTO ALU
Welle coed fo ol
1 SQL> select Intkeopl hello world 0 ott’) Lyon dural
MMiTene 4 eLke vont Au)
Halls World dio AU
7 SLY Set hol Bom diols
es
hot
SQLY Soteck Levim (hoi!) tom ;
LrTeRivn aa
hati
SQLY select rein (hai 1) fren duak
RT RIM
hot
SQL> satect that
! from dasrols
‘Har’
hoi
SQL> Seteck Shot ' from dural;
RTRIM
het
SQL > Seleck Concat C4EKU, University from dust
Comcat ('GEHu')
4
peer is
Page No-04fage No-02
_4 SQL > Seleck length Cqenu) from duets
LENGTH (4eHU')
q
4 SqLy Seteck seeplace UGGHU Unive
re piace UGeHu)
geéu University
~) SOL} Select Substr U Univenity', y, 2) from duct;
Svueste
VERSIT
SQL} Seleck vpad A'GEHUs Lo,! *)byorn duct;
RPAD CIGEHU
GEHU He eee
1 SPLY Solock tpad C'GEHU, 10,!*!) frem durch
LPAD UG EHU
¥ eee GeHU
7 SQL Seleck Ingtr Ceocaon’,$9!) fram cluot;
SPL) Seteck seeplace Urony hs 'yhsttet) from uals
REP AcE
Danie
SPL > Selock chranilate Ceatd! t
ahd 1d ott :
TRAN SLATE Utd Valt) from duset
3
Coot
SOU S0lok sysdate from cluet;
SY Spare
30-0cT-2a
SPLY Seteck pound (sysdaste) from duat;
ROUNo (sy Spates
34-0cT2Q
+ SPLY Sebeck ood— mondh
{ a
OO > MomtTH (sysdote /3) from dust;
30-JAN- 90
EHUIS GEL!) from church;Page No-03
AF SOL Sebeck lack-day (sYSdats) from durot;
UAST_ DAY
31-OCT-22
AF SPLYSeleck Sy sdotet20 from dual;
SYSDATE +20
a= Nov-22
I AOLY Selock nevblote Sy adote,Lueodag) from ducts
NEXT pay
01-Nov-28
SOL) Select tounel (15.6199) rom dusky
Round (1s. C49)
AD SPLY Selock coll 23.20) from Auch
CE 1x (220)
24
—) SQLY Solect floor (24-86) from duck
FLook (34.84)
34
A SGLY Seleck trun (18.5642) from duck
TRON (15: S67 42) : “s
1S
A SQL} Seleck Sign (348) from duals
SIGN (+246)
Tt SGLY Seleck obs {-40) from duck!
ee
to
7 SQLS Select power (10/12) from uot;
POWER (0,12)
100008 +12
A SOLY Seheck ynad CUS) from duct!
Mop Lt,s)
a.
3 SALY sabock enof (ol from disols
Ex? Lo)
22026-4ESgfage No. oy
PART-@ 4
4- Ldhok OL Sing a.
R. >
SEL. Lwplain By chroot MAC favs Tunckioys in Ovadte
Ans — Single Rav tunckicng —
SF oF
: sfunckt functions 4 dete
Function And converston tens Used cto grant Pulte
hate then, Requires one or more tnput On gurend
And operate on each TOs, the: Suadserning, One Outbut
Wale tery each pos, Migumenk Con be column,
Uderak or an Greprenston, Can ke Uoed tf SE
lect
Stoker, WHERE and ORDER BY Clause,
Multiple Rou Yunckions — Mubkiple store funckions Lo
Wen rave of poss and hatin ore sea th Lyon the
Complcte set of rows. Alto, Rrows OL Group =n
Aggregate tunckions ferforn G& vorkeky Of actions su
Gb Counting OM pos in a toble
, Summing NUrend
ode. ekews,
2- Notes on Following Types of Punckissys —
1) Types of Character
EE AT Snaracket funckisns
funckiong — Accepts Charracker inp cand
Seek Umber or Chara cher Value,
JF CONCAT— Concodenodtes 2 abhn voluer .
DF LENGTH — Rotiemns the Length Of the Snput Shing.
4 SUBSTR= Peters fonkion of Shing trom given stot Polit
to an end fdmk,
INSTR = Rekums numeric
Given shin
4
ostkicy OF charackw |shing tn
9
4
UA0 and RPAD- Pad dhe
given Shipp upto a spect Hie lent
lucth G& gtun chara cher.
4
TRIM~ rine the Sting Trput trom the Shark or end,
7 REPLACE Rarlacos characters from tnput sts
Stven characer ,
\i) TY pes of Number Sunde
SUMS Numeric Valuok,
"9 with
— Accepts numeric input ane
ROUND and TRUNC — Uned bo touncl Oyal runcode th
+ Mop— Uned -to petsem porneinder af divtesien bet
re VeliePage No.05 |
ri) Typer of Dake Function Rotims clade or numeric volute.
A MONTHS BETWEEN — Retuma dhe count of montht betwen Ave
does .
ROP MONTHS ~ Acld 'h! number of morthi Se On Mnpuk dot
J NEXT DAY ~Retumt the nent day Of the dobe al
1 LAST— DAY ~ Rekums (ask doa of the tnanth of Irket a
J ROUND and TRUNC- Used ko -nreund and truncate dake
TY) Types of Conversion functtens = Accopks Characker infut and
Stebums a charackey value.
—) UPPER- Convetes ating -bo Upper Core.
-F LowR- Converts sting to Sower cose.
-V INIT CAP Convers “Wiel alphabels of c. Siang Ko upper Com
v) Ty pes Of Gentrak Punctions - Usuebly Corekeing NUUL Wendin
tunction s, Replace NULL Values Utth on alierneds velue
NUL, NVLQ, NULLTF, COALESCE, CASE, DECODE Gre geren
funckis,
Ni) NUL Weth 2x ample Quester On obberneke Value dor a
NULL Velue,
Symtere— NUL (Png 4, replace alts)
SJ- SELECT Firstname, NUL (SoB—ZD, 'nfa! )-from erp Loyeat
Vil) NUL uth ecimple- Used ato Subs dikute on ethers
Volue Hor NULL OF Wel Ot mock NULL,
Syntox- NvLa (Sing 4, Voluei _ NoT_NuWw, Value TLNULL
4
£4 - SELECT NUL (FoR-cook, ! dob Assigned", (Bends!) from
ern pLoyens}
Vit) CASE Lott emample — § earch Steaks from Let urd move
Howards Sight Until Uk finds a Barus carditis, dnd
| than nebirns merukk Obtocladsed usdth Te. If mo ‘coukii
Ue Fra Dhan Oracle vetromt pest defined with
Ure, Odeniue, At nebern NULL.
Maximum number of Orguments LU 26S,
& - SELECT Fyne — name , CASE WHEN Solary C200 THEN 'GRp0e
WHEN Sotory > 200 and Solang CSo00 THEN! GRADER!
ELSE 'Genne x!
END Case. fron ernp LoyoessPage No 06
tx) Decode Uicth exanfle = Wows with vetoes | columetl
exireeans of cM clots. zypU. Compares Qe preaston
Ogaintk ach Setrth yolua in orcler. She moccimum
number of components in OCore furctins 25S.
&3- SELect Hivak—norye, golary , DECODE (hive debe, syidate ,
‘NEL ToInee!,! Brartay ee!) {oorn errployeu ;see list of tables by using “Tab / cat" tables
Practical List 6 -Date Time Etc
_ogon to Oracle using your User Name
create a table “Employee” with following attributes
EmpCode
EmpName
EmpCity
DOB
DOJ
Salary
Display the structure of table
Number
Varchar
Varchar
Date (date of Birth)
Date (date of Joining)
Number
Insert the following data into the table (Convert Month No into Month Name like 3 = MAR)
EmpCode | EmpName | EmpCity Dos DOJ Salary |
[1 |Yogesh | Dethi qnai7s | 111105 | 12000
2 Dinesh | Dethi 2215/78 | Current Date | 6000
3 [Sheena |Mumbai | 16/6/89 | 1/69 —~«S0000—~*S|:
5 [Sunder | Delhi 1718/82 | Current Date | 4400
|
Execute the following queries and note the output:
a
b.
c.
d
Select Empname
Select Empname,
Select Empname
Select Empname, DOB , DOB - 3 from employees.
Select Empname
Select Empname,
Select Empname
Select Empname.
employee.
Select Empname.
Select Empname,
Select Empname,
Select Empname,
m. Select Empname,
, DOB from employee.
. DOB, sysdate from employee
, DOB , DOB + 15 from employees.
, DOB, TO_CHAR(dob,'DD MM YYYY') from employee.
, DOB, TO_CHAR(dob,'Day MONTH Year’) from employee.
, DOB, TO_CHAR(dob,’Day MON Year DD MM YY’) from employee
, DOB, TO_CHAR(dob,'DD DD MM MM YY YYYY YYYY’) from.
, DOB, TO_CHAR(dob,'DDsp MMsp YYYYsp') from employee.
, DOB, TO_CHAR(dob,'DDspth MMspth YYYYspth’) from employee
DOB, TO_CHAR(dob,'DDsp MMsp YYYYsp’) from employee.
DOB, TO_CHAR(dob,'DD MM YYYY HH MISS’) from employee.
DOB, TO_CHAR(dob,'HH MI SS’) from employee
n. Insert into employee values (4,'Amit’,’Meeurt’
1-Jan-67', '21-Sep-04', 15000).Select Empname, DOB, TO_CHAR(DOB, DD MM YYYY’), TO_CHAR(DOJ,0D MM
YYYY’) from employee where Empcode
DOJ? (Is it 1967 or 2067 , 2004 or 1904)
p. Insert a record with DOB = 1674 , and DOJ = 1734.
q. Display this record with full year in DOB and DOJ (
=4. In this query what is the full year for DOB and
{as in query “O")
Write queries for the following
a. Show all records
b. Show names and Salary of all employees
¢. Display the highest salary
4. Display the lowest salary
. Show the total number of records
£ Display the emp name, actual salary and salary with 15% increment
2. Display all records in following format:
© The Salary of Yogesh is 12000 and he belongs to Delhi
© The Salary of Dinesh is 6000 and he belongs to Delhi
—— So on forall records -—~
h Display the total number of characters in all employee names
i. Display all employee names in Capital letters
j Display all employee city in Small letters
k Display all employee names in Initial capital letters
|. Display only the current date
m. Display only the current time
a. Display the current date and time
0. Display only the current year
p. Display only the current Month
4. Display all records in following format:
2 The date of birth of Yogesh is 1 November Ninenteen Seventy Five
Display the total number of months an employee is working
s. Display the name and age of each employee (Do not show DOB)
1. Display the total experience of all employees in years.
u. Display the full 4 digit birth year of all employee
\. Enter a record with your detail in the table with your actual DOB.
Display on which day (Mon Tue Wed Etc) you were born.
x. Display list of all employees who were born after your DOB.
y. Delete your record
2. Again enter your detail record and this time store your Birth time also
aa. Display names, DOB , Time of Birth , age of all records.Page No- 04
[ Nawe— Neha Kumari
pectson— x
Ytudtnk SA— 20012648
4} Conn C829 132;
Pass 2 abcd;
Dea
2) Select ® from sab; : j
Select * fron Cok} cae
3) Create table Employee (@mptade ny
Empty Varchar 2 (46), do&gdate
4) dese Emplorees
A p Nantes Varchorr 2(14),
’ Sohary Trurnker) 5
Nate, NULLZ Ape
EMPCOOE = MOT NuLL NUMER
EmMenaAMe VARCHARZ C16)
eMe city UPROHARZ U6)
bog DATE
Dor CATE
Saupey NuMeER
By dnserk fino Ernployga valves (4, +
‘oa. — TAN- 0S!) 20.00)F
dnsenk tnko Emplayes Ualues (2:tOinesh}, (DUI! 122 - MAR - 78",
Sy sdoke; 6000);
Yogeth!, Bett! ! 04 —Now-FS!
gngenk Inco Srnployee etues | 2," Sheera!, 1M Umbal 46 -TUN-897,
‘04 —JuN —49!, Sooce)y
Snsewk into Employee valued (B, ‘Sundar, Lous}, "1% -Prg-A2/,
sy adaoke (44oos) s
B) A) Stack EmpNane oR em :
) ) SeaPupead > 28 from Phoyess
Yogesh 04-NoU-4S
) foes Emp Mane, 008, 54 sdate from Syrployee;
ETAPR PIE Dok SY. StATE.
Yogesh O1-Nov-¥S 42-Nov-92
; Emp, 2 B+lS from Employees
) eieninnes og =? Boe Qee +16 From Employee
YegesSh ~~ O-Nov-AS ~4 60-Nov-46Page No+02 |
a) Select Empnaree, Doe, Doe —3 frorn Errphoyes s
Eves Ame Doe ooea-2
Yogesh Oe Nov- 48 a ooT~a4S
) elect © mprian, DeB, To CHAR (dob,'00 HH yyy!) from empoys
EmePnNnaAme Dok to SIAR
Wgeth ee O4- 44-4995 |
4) Select ene roe “To cHeR (dob, Moy Month Year) foorn tmyiap
Emrunme - a TOW crear + (poe),
Yogesh” Menoute _Sphurdag Navenkey Ninetan Sey
werty, Pre
q) Select Emprasin,,boe, To CHAR (dob, tony Mons YERR 10 mecHy
~~ from Employees
Euruame don
1 : secteg Nov ieee, Severty Pde ot ws
h) Selleck Emphante, Dew, To
tren
BHP eMe deg ace To~ CHAR Coe’)
“peak Ol- Nov-¥5 SL ot u
CHAR C dos top no Met bis yy yy oy
WAS Laas 14a
1) Select empranse bos, aco
Employees
EMP AME Dok TTo— ch
Ql-Nouv-x¥ 9
ca Hes
a) Sele ck Errphonte, bor, — SIAR (dob,
Errplorycas
_EMPNRME mr are CHAR (pee)
age Sh, or-nov-as Fink fhe Q o red Sve
Te 4 fice North One Thotwcord nie dtundved <
SY Scteck Seta bon,
SHOR (lob Os p Mrgp N1sp') fo,
> PRspth MAM goth NY sett) fy
> To— CHAR Cahoag 5'DD HM TY 4m EAE ssi)
From Loree s
EMP rere ee ie. ~ CHAR, Choe)
12 00 00
Dae Ol-tsou 4S or ( 14ats) Page Noe 03
[m) Select Emprane, DOR, =o _ CHAR. (dob, Mn MI S88!) feomn Pong loyee;
EHRNAHE Bek | “to CHAR,
Jogesh Ol-Ktou-34¢ 1200 00
n/) Ansetk trto &m ea Youd (4! Pm! "Moone, "ata, ca!
21 Sep- oy? ae 7 oe
A vow Created |
0) select EF
> (805, top erin: w» Grape Vala YVPY9, To car
Engle Lidia rom Emplogta ushete Errpcode 243
OR
“Arik Okami ap a eee) To=cHPh C003)
ow Ol el Ge = 8 | om Aca
P) Snsert CC record uth Doe = (644 And POT = 14343
p) Snsent Trbo Employee Yalucsd (c, "Aran, (ACM, VoA- Nou —| cot"
Roose, 'ol- TAN 1 424") 3 :
a) Select deb, To_cHARr (dob,' oo Me YT!) Ao}, To_char (doh 0%
YI teon Employee where Empcade = C5
Doe Te -sHAR (078) _ Pas (-To_cHhAL Dou)
Ol-NOUNY OL UL GHG Ol-TRN-2y OY OO: LF By
a)a) Seta ck* from Employes 5
BYPCmE EE MPNAMe EmPCITY Dem satay dor
4 Mogesh Beth SENUAE [2000 Ol -JAN-0S
’ ¢ 8
¢ t «
b a | onho, Ae ie & ploy :
: Cumnue ooaet wees
egesh (2000
<) Seleck Max Salary) fron Employees
ieee ne)
S0000
A) Seteck MIN (salary) from ErnpLoyens
DAN Lsetary)
Guoo
Seteck Counck Ol mi 2.0}
cauwray em ners
aFy Select Empraute, Sot
Page No. OY
1 Solar dt Galan ae +15) ireve from Employts;
Empisne — Soles yy dnd
2 egh 1a c =p
18 aI as 1SRv0
h) Scleck LENGTH (&mpasns é .
’) LENGTH (Enghianceh ) fron mphoryees
4
a
é
4y
y
1) Seleck U Pee LEmprsarse) drronn sous
Ute nny) Ho Srey
Yoqeuy ~~
F) Select ‘Loung ern, '
Lower ote hom Errployte ;
Yeh
W) Seleck tate
cop Lempciss from mplayer:
INUTCAP (Emp C3
uae a ie
Y Seek sy Seer. frem duals
SYSDATE
IS-NoU-22
™ Seteck Curmerck TEMS Steamp From dul;
CURLENT time STAKE
IZ-Nou- 29 £0. 14.08.2 C0000 fm - S800
0) Belek Vratrack YEAR trom Sysdode} from ducts
EXTHACT CA YEAR. Feo Seong
ad
P) Select enkrack (Month from Sider} froin duck:
ETRACT Wont Pott sysonTe)
2
Wy) Seleck "The dose of brash of “Yegeth ts'44 to_ chow (ob)
month Year") Born Simplayee Where EmpnaWe = Negeih’ ;
3) Seleck Emproice , ertacck year
firom sysdode) — entrack Crear
From Cab) AGE feror Ernpdoyes}
BrPNAME” AGE
“ogeefage Nor 05 __
Selec ErmpNahe, Eetrak Wear Tram ayehite)= Pract Utes
' Near trom $ Se ok Weer
ol mM doi) Experience ee ae “
Ernployes;
ErPNAME BrP E RIENCE
Yogesh a
u) Select TO CHAR ( dol ermployre *
' ek BINT fron @rnphoyne;
“yaa
vy) dnsent trto Employee values (WU, !P man! Wdebrodun! No- bec ~
aol, Syadoke , $00 000) 3
ws) Stleck To Hag (dab 'day'} fron Cinplayee cohere Erm phous
2 freman! }
To AK Cog)
2) Select Emrprane from Srmplayer Lohere To cHAR (dob, "Yy
720003
No TOUS Sele cked ,
Seleske ’ ,
g a trom Employee Uhere Emp tants Pee mean!
aa) Seba ck 1 A926 4o_ cha, Cd e
Lyear fram sy sdode)— (tee ae sae
ne ; J~ erbrack (Year tran Let) tye,phoe - Meha Kumari fet te cee
Sectton —
Pott No-— 32
stadt Ta- 2002698
a Corteian— Also Knoun as Crogs—
a Fist step before few taming a
aA Cartesian i, GQ Cross — Predug
a Lstth ol Los Of relate ‘
42 Systane of Cartesian and Join —
Wy ANSL SFL Complore Syntaoe.
uy Oracle Syretan ,
Consider the Fall. 2 tonters
SAL Selock* from one; SL > select + from toy
NAME CUTY, NAME Hoeey
ae aa “abe avichet
aed rive: ae ae
mee aeln grt Ratnsing
ghi Laie e oie
hod det sprees cle!
2. m AkotnG .
4) ANST -Sy nto for Cantestan —* [ oO
Seleck ® from One cross Spin sw;
No. of youss — Q2Uleay)
and, Norof columns -4
Only G6 records Gre Correct ih cbeve QU recesds,
oa aoe
TSO Rw track Ase Correck @ wrecerdo use need bo
perferm aire on BAK camte sian,
* TONG A Toin & a canditien Oppred OR a Cantesian.
Shey ane of vrany sky pes —
ty Equi Soin | Inner Toln — (=)
S9- SPUD seteck F from one ,siwo Usthere ohe, name = dws
NOK 5
GB vecordls proud be abstained,
ub Natural Join — Shouid be Ucoed with cone
€g- Seleck * From ong neduot jain dive 5
“NAME ety Hobe
“abe “ddn Crvele ek
Ole dan IsShp eg fangs Now oa
eg- Alsplay hata ly of Employeas along uinth dheoly chopt.
2 ee
9 Select ¥ from ap, Lep arndrmeree share hapt = dlacdes,
EMPaook NAME
MANAGER, DEPT Ocone DNAME
pilin’ Locntus
6 tanun 2 lo lo Goleta ahi
+H Ruta 4 to 10 Sotos eh
ily abe 2 lo lo Soles Pelt
3 Rohit So lo lo Soles LT
Qs
Mohan 4 do QO arlecking Reprba:
S alehtl 2 aa 20 y
ay ; ProcLusctisn Dalhi
eeres Ss Ge to 7
4 racking Ronfun
on Ruma ~ Yo Yo Rech .
(DSeLeck *, emp nakural join dle pantorents
Nos of rous- 66
Grdy No- GE columni~ %,
W)_Qudey Soin — 2 ayrcka— GQ AMSE Syrdowe O) Prepi etoey
ej- Sty 7 8 from @mp, claparkmank whore cpt =
decode (t)3
44 vous Selecked
dnd, + Columns gelecked ,
+ Case of Right Qutty Sen,
@ SPL) geteck® from emp, cLepandemerde ushere cept (t=
deodes
4o-roun selocked
Ord, Jt column selected |
ee Ousey Sein.
@) SQL> Sele & from AP Oustenhoin cLeparkmtrk an cept
= dtodes
13 tours Selocked ,
Grd, + Columns sebethed,
Cone of PUL Ouder Sen,
tv) Self Tom —
D Se ak * trom emp 24) @mper Usdhere @ls manger =
Ca. empcade;
& vous selocked , .
SPLY Selock QUs Sim pCada (21> NAME, 2a. nane From
@® seey ot f tl t Ai
emp a, emp Ca Where 21. manager = C2. empdak;
& vous selacked ,Page No-«3
a) SLY selock 1. empcode, @ienatte Co. nane, THaragen
From np 1, emp Co ushert CL Manager = @0 + Onyptalé
§ rou Selected,
% Subquery- pA sulojptery Co
fngide Another wen based on a tequtved yeoul
.
Ip Displag mares of hose Lo who are Uworlting
re Fada mene ue ee a
7 Select nawie hem Smp where dept = lo;
uy Juplay Cocles of srose employees who are nak
Gdttached cho an Ondinont «
“sack onpeade fom np ates dep 2
inh Display hares of Mrose employses who Cine
Luorking tn Sates menk
—} Soback narit from emp where cept = (select
deede from depcvrtmenc -ushere dante =! Sau!)
J} Select deade from department cohere drarce
=! Sales'y
{UY DUP OY pared of rose em who are :
re re, dei t Game a
> Seleck nome from emp where dept in (Select
deade fren department Luohere location tn
(delhi, 'Bemboy!))$
Vy Display bigheok employee cade.
) Seleck Max [empty from emp;
vi) Dlplay and highest Employee code,
+ Selec moe Lonpcode) from emp Where emprode
Sty nok ihn [select man Lompcedtas ee emp)$
vi) Display ad highsok enn cade,
J Select MAM [empeade) EMP Lobere emptade
C (geleck moo ern pcacke froin emp cohere