DBMS Lab File

You might also like

Download as pdf
Download as pdf
You are on page 1of 20
- cemmandt: 4 SQL with sullaate \ CREAT ER ©) CReate TABLE : this Jy aud to wouale a rw 2Ulalee (tobi) Syren CREATE TABLE < suttalion nome /tobu name > Cfuld 2 datatype ( aizay, po dolo-typa tains), 5 yp EKtenple: CREATE “TABLE Student Lano NUMBER), sname CHAR(IO), clos CHAR (5) 4 2 ALTER’ ©) ALTER TABLE ... ADD...$ This Wb std to add dome exdta _inb—existing gwlalion: Synbon ALTER TABLE slain rma ADD Cru folds latatyps (421), aes sna fildy° dlolybt (A235. ) 5 Exomplt + ALTER TABLE Ald ADD t Addu CHAR (10); (b) RATER TABLE. MODIFY 3 “Tha is uatd 40 chong IM nilations Oe tae ihe Spb = TER TABLE slain noms MooiFy [ —4 munolota iy 5 we (aus), ld 2 mundola ager oa 5 o 4 quTeR “TABLE MODIFY CAdmame VARCHAR 0), class Example VARCHAR U5) + EPROP... 5 Ts 4d addi 12 sumone, c) NCR sults “i oy? ALTER ste SN nore ORF COLUMN (4uifol ram), + MTER TABLE Audit OED? column ¢aname) « amp? W) ee ALTER tague REwAme TNO iy ud 40g 4 rl swlatrons - 2 i Syntax « AYR. AL 5 t TER TABLE as RENAME cocumy (up fild-ra we CM fald Chomp Acre Reerata stud See int REwame COWMNE Snome fr atin % OM Titel ae Wud to delle the suai . 14 7 . dil ee hay U Sees Roe TABLE tlation maint Exdmbl : gee trace dol’, 3 3) Tmplumeniation of Ome cortnands 581 with ssucadeee extumblts ¢ © Trav « Update o Hele INSERT INTO ; Thu Us wuld to odd sucords unto 0 yulnteien That wu the typi 4 INSERT INTD yuna wtuch ul as 0 SE i Syriltoe INSERT N70 py Meade il ph oll jhe satis i sulation ay soll: of (s) amo then thomforo ltelid of fr guloer 7 FROM 4 sulatien roe > GROUP OY 5 : geeecT cut ils Ggetaoh : SeRPCT © G14 cine Example", suet Empno , dunn ( bolouy ) from emp GROUP BY empnos onROUP Haul Te wav elu wea icdid 40 SQL bicattae 1 et Puente repo el) ue LUE 7 on « Ta HAviNN4 fae mua 600 Socal er j cin by rd mult aldo utd ye ee tigate - fumelian (C6lumitry ee phe actin ne vant opusoler va GROUP BY eatumn name Havin CCobinmn rams) opocater vatus i 4 opel parctein EXombU + ge Atm : Select 4 lostlloms COUNT (ordur. arelun I) As ON aso Employ = Empbyes » Employcrte ) Gpaup By Aaatilont HAVING Coumd lonlws . wdirTd) >10, * ORDER BY: -mu ede dy acca eb og pil quem a sulation im an Srdoud manor boar gn dome 5 fio - Syntow Se Lect cau of ula > F < fulld naame 7 Examblls SQL> sevect ni ,eramt, yob PRIM tm JRDER BY )b5 LNOCCING 5 Am unde JU am vendo ih pouder 149 dala a Se a Ree Sapa tah valu in ene OF mit colin of Hu table, S§L Bat Hos dmdtoud apoyo dt €pulton var > OR DER BY amburus TA table with a unique maine ° a a OU uth «the Jom veh an th asm os column thet form tht umd Kuy ! satinib 1, ane FNOEX =, cx phe.) Gps 4+ SWo quia Frat Guts suusial valu Sub Qunruld com algo swhihnn mere thon ent valut . gurls sual dhowll 1 made uu along wilh vet ofsrabors in dreh omg 1. muddle qual i fu mere Phare ent dub quoy is ubtols Hunt mbtipit ab qubiae wr comma ty muons oa and7A ‘os Kiguerdh. wg ft 1 i Ee 4 Stud De Se tenbliemimtntin xf Auth Wneak bob TY) lew Lum adel i Sge U9 ‘ fume R A wu) oma punt sp ath ERE, Oma Tain) tatem d nent pom ne. drat i ow We ; otra cb of alata. sl coming Wd Ag yu ob rUshich cenaiats oO det q ; {ee on ay move table mila colt. ou met otore hat tat fe { Ae ee sien il i ao Unb tut UE Oo qu ecered os om obpek. Syriaw : cReaTE view < wid nomer AS SELECT «aut ; fe PROM sulahon moma WHERE CLendition Pron erat abe trample ° combi cw EATE VIED & MH SELECT embno, rant , job FROM EmP WHERE job = "elu? ; ; 2 vd guotid . examples cRERTE VIEO [omunt Padus Uist] As eee 1 Pruoottet Name fRom (models WHERE Haarselinusd = Nos 5 A ww com upload OY utr ah felon vpiating 2 : eo qui nant AS syste: ceente oe epeace “ Syatiint gevect cobunna-vanre ) PRO tell rant - were conlille Pied connor! ; wash vos QROP ELD Com po tivg a vin CA ern oft A cer vier 4 @) 2) cua, in of ditt ‘ Constraints f uy ypu of, cout travian uur ald Yo St «Olaf: cin abl GH Hius Lj sample ta Soibiainy amd tne tte action » yd chon dee ae Unabevinls Te an ke aptiitd wtun w tabt “Any CREATE TABLE eblumint) ot says te dnb Custvg ALTER TABLE atatununt ) 0 4 NOT MULL > wun a veolumn Afoid 99 Hor MULL, Hen Hah tolumn -bicemu a mandatory eblomn , 1 plik tak 9 yalus ut bi entuad intn dh Selumn 4 Hu steebrel ib to bo e secppted fe Merogx in the fable « Syeletl) CREngTeN TABU en Teme ire eierne tran eae Let ) Be Not NULL) 5 Exlmbu t cReATE TABLE Ud L.A UMBER (3) NOT NULL ,ramma cHen (iol); v 2. UNIQUES The Aone @ umigut fay ib 40 enuuor Hak 5 Sm He glut) Yo umyut ie a yalut entsud im eglumag dred in de Lonuduind must not bs sefptotd accel Hu v @ vere), ptobl may Rade mamy wig jays. Syl ! CREATE TABLE TabtL nar (Ortumn-rame dtp (SAU UNIQUE exomph: CREATE THBLE Auclent (ano NUMBER (3) UNIQUE ams CHARL2)); : thot each sow in He sub TULLE : ie F Ye 3, CHEE: Spy Meee | each Sow rare shy comabitise oul TRUE OF wee viol smut 4 (as too ut) CREATE TABLE Tabl-rame ( trluumn —naene “dah. App tas ) CHECK, ops Copal exysultion JJ CpEATE TABLE dtudmt (4nd. NUMBER (3), nomu CHAR (ie) wipss CHARIS) CHECK Colas TVC'ese', ‘cad', 'VLST'Y & Po et tA ful which A aed 46 udlinlify a ence wiuyuily . A column wr Lombinod tn 4 rolien bee ES) anova Of column Sap kay ustich 4 Hyhimer prone gidey dats), rd COM BE uid 4 in n ei As eroten ou Mauty table Loublt eevee osrnasly a 3) U mut wrquily daurdity each spucerol on va table > TF mut vento uougue abun TH counet be a mull quite He aust be mull pert fold > Ta dbewtel contain gq minimum no 4 ¥ files meermory 40 be ae called eq StS cReATE TABLE Tapte -narme Ceglumn ram aS me PRIM BRA KEYs ExumpU > CREATE HOLE fpr Heo NUMBER (3) PRIMARY KEY» ee frum. CHAR (103) 5 5» FOREN Key: oh yo dobl dul erubdw we me ts at column dul. To Huguet tae th pa column sothor dab hy ee eam cok Lat utd See let hy is Lajas poo Sap ec. eld oe male wal > js Hypsncd shy Hee farlgn. Siete + CREATE TABLE abl column vara dol bebe (130) a 6H KEY Ligumn.ntrru} REFERENCES Labi rang Examplts CREATE TABLE ubyict (scoot NumBeR (a) PRIMARY KEY, dub mame .CHAR LH), Feoll NUMBER (4), PO REIGN Key (ents) PeEPERENCE Facutly) s ating Oaloboar | Tabu space ¥ ‘. soe anoltti, Ode See eo ; Cyn Sega consis win tht wlfor table com Sato s ALTER TABLE JabU-namu ADD PRIMARY Key / colunm nam ae ALTER TABLE student Add Primary Key (mo); o Sqrclk $ ALTER TABLE Jabli -nom ADD CONSTRAINT eonticaint rat ‘ PRIMARY KEY (cotnarme) Aomblls ALTER TABLE siudunl ADD awl STRAINT sr PRIMARY KEY (ane ) Qyeppe ‘ntagey conabitinks um te wltey doble command ; Sipedtnt > ALTER TABLE foburame DROP contnaint—ramu > exomple : ALTER TABLE student OKoP fRIMARY REY; ef be) , Syatari + ALTER TABLE ae tenabuaiml nome; E 6 STRAINT An % examples ALTER TABLE OROP CONSTRAINT 405, ef y alt g DepAULT cenabhtind Ju uuid 1 wrinucl ox OH 6+ font an a column "The dif th youu wll be addled fp all nw) Pecado oto vou - Surbnok + CREATE TABLE dnbt-varnt ( tol-nama cola? loans 9 OEPROLT ‘!)5 2 Lea ene. le a to yom HARUD), clas HAR (22) Oe AULT \ purtargabod MARC Imblomrurdation 4 ROU back y Lommit y Sonu point \ Commu « i an + Thu temmand bud 4 end a adnongoctian wl by Aub af i commit Command Buunnetion chon . mode fommavint 4) it clatorour. j a Syed + Commirs euamb# 3 Comm 5 SAVE POINT ; Sonu porns ayr_tbt vmaiRs 40 chide 0 rH Aumgtty Bumaction Yo duvallor ores - Ta wou ual +0 vdunutify a point win & dXomgociion +o ustuch Ht Com Lotlor ule bork: Uy AeA pounk Gj unl im carfamctuer suit all pask - ae Caarenple + § 5 gave Point Td; pve POINT X42 rat ege sao Les) pe eet Cee a Ms, na jo wot 4 SOL pemt a voll bock- aialumunt ote tht dat gacx Convert promsasuer com bi Sprit 3 goul i f yy ort BAEK #0 Sant Pairs TD; not back) example RoLl BACK iB RoLiBAck To gave POINT *YFs O} Gunting Salnbout, | Table pore \ Managing Uda ~ Gun, wun, Cove Ald * Mor Posy wordt + Maange Hol i. Usa y Revokt CREATE USER? Tw OBA Cal HME by exueu Caan statment « Wain da domuont hb connucl Jo We dlolebaue Jf eouy pdaitens a pasted Syria + oReATE USER A> CREATE USER < Uduinnrntr © - (n entices B i Capra of Wir to bt uated ) TDEN b BY Revone Pitigns Hic an | pile on ap FROM “wer Coetle cual sud REVoKe dled, sicink ON emp PRo

You might also like