DBMS File
DBMS File
ALten Table
ALTERTABLE enploye©s
MoDLPY catmmm et-olatatpe ADD em ail VARCHAR?
Dop tble
DROP TA BLE employees j
uneate
TRUN cATE TABLE tablenae;
" Rename
"Seleett
Syntaz:
FROM tablemame }
" Delete
wHERE Cardiion ;
a. What are the different ways to insert data into a table using the INSERT
statement in SQL? Can you provide examples for each method?
Ans:
To add a
Canit aint ALTER TABLE le- nae
ADD coNSTRAIN T Canstraint-ume Cornitrantb
Ctslumn-merE);
To madi a
ALTERTAB LE tatlemame
()
no DI Y coNSTR AT NT Cantthaint- rame
muecantraint defintion ;
To drap
ALTER TA BLE t l e a e
DROP CoNsTRALNT conatraintMame;
Divisian():
aliasae
FROM tablemaes
WHER E cantiom>;
PowER c^): SEL EcT POWER C6 aue, expenent) As
aliasmne
FROM etable name;
FROM olual;
SELE CT 2O /4 AS quotient
FROM dal;
SELECT PoNER (2, 3) As neslt
FROM olual;
FROM talemame
wHE RE Candithien 4. oR Condiisn 2 OR.
af
"Pupose: Ceunts the mum bun
Column an tab le.
cutames,
use Case: Ceuntina the to tal mumker af
anders in a databae.
ynaducts , aM
2 SUM)
the 6um of all mmerical valus
"Pupase:- lallates
a speeified calmn,
total sales tatal
" Use Casei
caleulatin the
total imvontwg value.
expensey
"Pwnp ase- Caleulate the aMerage value
values on aa speetied calun.
taleulating te avenqye solany f emplayeesy
OMeage precluet plee , a anen age ader value.
aviage
-Calumm,
FROM Cuatemes
LEFT ToLN deolos oN eUETO Cuutemecs,
CustameID rddos. utomoD
ORDER 1BY Cuuternes. Custorme Norre j
Program No. -8
SE LE CT *FROM Fist
MINUS
SELEeT * FROM Secand
b umbu (2) =l
Cnumben (9)
while m >o
loop
P'rogram No.9
deolane a
mamben (a) &a;
b mumben (2) b;
end;
5 78.5
3
meue : cnnbe1(4):z Y;
PL SQLptocedwe sueceshuy guateut y
3. Question Answer PLISQL oudwte Sucelsully tungl
a. What are the primary control structures used in PL/SQL? Describe each
with an example.
Ans:
<bunotten bady
END CHunetian.mame}
Calling
DECLARE
c mum ben (2);
BEGIN
END;
Ans:
b. How can a function return a value, and how does this differ from a stored
procedure in DBMS?
Ans:
2. Question Answer
a. What is the primary difference between a procedure and a function in
PL/SQL? Provide examples of when you might use each.
Ans:
the
b. How do parameters work in procedures and functions? Explain
difference between IN, OUT, and IN OUT parameters with examples.
Ans:
Ans:
ProgramNo. -10c
I. Objective: Create triggers in PLSQL.
CREATE TABLE Cmploy ees(
Cmployee-id INT,
sutaname VARCH PR(Q55),
laut.mame vARCHpRC265,
Salary DEczMAL (Io, 2)
);
eR EArE oR REPLACE TRI GGER gdato salany
BEFORE UPDArE OF Salay oN empkbyees
FoR,EACH RON
8EGLN
TE :NEN salarye:0LD Salany THEN
RPISE- APPLICATION ERROR (-200o t, 'Salarå camnet ke oleeeaato }
ENDIF;
END;
ZNSE RT INTO emgloyees (erplay ee-io irut. mame, lact mamey salamg
VALUES
(I, "Tohn'oe, 6o000,o0);
UPDATE ernployees
SET Salay70000.00
WHERE employ ee ioh =l;
UPDA TE employees
SET Slany z 8000 0. 00
wERE employee-id=lj
utt: