0% found this document useful (0 votes)
18 views30 pages

SQL Notes2

Sql notes 2 its for used to study any kind of data structure begin to end
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
18 views30 pages

SQL Notes2

Sql notes 2 its for used to study any kind of data structure begin to end
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 30
Rig) do _favie2 ony apie (+ Con Have? CONN _Iteet sebie. and men tre _ __Sevect_ Tavrel. on 1s ined Te Ra € Mattined deta from +ne betin Fabre: Aned iy ei print ame _unmached desa i frem migni tere Jee sa ee . _Selechr Tablet. colt, Table 2+ Cola , Tarte 2-col Aable 2-Col2» «+ from Tabre 4 fommon Tanie See orn Prom > both: sabre Linen iy eit! print tunmerthed dec in print siqnt stavie _tamethed cteetqe Colt, Table 2. Colt «--. feom _ Rachie { 7 a Furl 501 4abled ON fommen— Fabre Le Commonco\ {| = Tape 2. common -calt ‘ Hy pFIO ane A deg Pan tne Poin Sisle tang,” eo 4 csi_print_uo-marened Gero Prey yeft +ob1e - ued te Syntax * oneth sapiel. Td - sable 2, Marre Select ‘Tabte |. (oll » Table & + Cold» TSHIET ss fFavie2. colt, raple 2+ COlZ ge ** 7 “grom tavte t : i LERT 2019 80 Ae taple2 ON Acie lcety = _ravte a+ Co\t } Ae - | Commen cevole- Jor | “A S&L SOIN Clause 1S Used +0 Compines the LFOWS Fomm vee a AS@L Soin Mowe Aanies. 1S _ursecl do Piles ane wecords Hon your canditions. _ f A SQL 93019 46 Mmesiy used | | eve. Stored procedure) Foe Qenevono ane weporie | || Tapes op anes Joins ? Et \ Taner. doing ' 2) LEET Soin _ t is Aqny oon 18) 29, 19 Lay Cow sovn ot 4 ‘ ee | S$) Serie >oiq : T Taney JO t\Tnnex is usem +e print ane + is : a e Lonmin) matched data fsom beth jne tabie 2) Suppose nou have tevo sabre 1S dabletana | Aewle 9 ANA anese tavieS Wave a cammon tasie rte — = —- Se Ahet time You Can We athese Trev doin , t cy otay — _ Selechk Aoble £. Colum, tavted- Column, — Aerble Qe Column ty = +++ POM dele, | Toner NY Fapled? aN table L-common..cotumn, Common — column 5 Copy an tne T Columns mm one Aevle Fo anotna [tebe + ISintax : -SUSEQT _TNTo TApLEREAME sevect # FROM THBte WHERE CoNOT TION « A: Inseet sorte TABLE FReM HOCLECT % PROM TASLE 2! D coitvnoeet Geacdsten conee condition. LEMSteT arto THBLE\ SeteeT # PROnned ” ‘ ‘ , TASERT TeTO TABLED aves Ca, Rect | \ * ve umn CSO porn emt ae Serecr name Sum Cuan Room Pou, ee ee Nam e+ Tova Sum sevary oF — Igevect city, Sumesata®y ) freon EmMeO Gpeup by ihe tN: clu Mew vo gind max f te Saiqay "9°" Jservect max (sar ) Grom _ emploxye = Dare Vote de find aetoned max Sola 2 | Sevect Max ( sarary ) ) fram employee —Hectq sonere Satan} LC Serect Map C Sendsy ] from at | emgeyec - Derg v7 T_mag (Setar) Crom eno there sarary df — Crstary | Prom Emly tonenc catary Attegs any. Use oer 41000 | 2 cata AS000 2 ~ ena ove Impricit index ore cndekes ANA CE attora,” Qrecred by Ane databace sevver Mage uy, “tt labiect is created. : __jindex are actomariceny Created M7 Prima, 1 ke, t Tonsirctinis add udique | tons treats. __* seo prem ocer ___icgeate TABLE Trieex - Exarr pce ( TO NWvsInseée, “ MATE -VaaCWAR (100) a | {| Ji) ep 2) UNTQUE THOER: ee JUN TQUE iodexr Ured ato aot ats: pefowmanae , But DO RE data _integmity. ° i i uA woique vey index does et ates any dablicere UNatues te be neerted: Anto Aapie W'S | Commenty: Ureds 02 “Corumns Vike emai) LAAABESS OF Other eet dela where umgueneSS y ; (8S Cvercian- Snax: . . = Creare dadex indeg—-Name on jabye-tlame (ol Name) j * Unique inser 7 Lewecre WAeX Index- ani 0 Gipreyer (ema! Jy 5) [compesit tneex 3 eae ait LOM poate index 1G ued TH an _inaex. dq two 2% More Columns af a tabie | _ : Hessgen x = — = —— _ oe LCecaTe THoey THEE =KlAMe DN TaBteName _ ONG CB oe LGramyie eee, CREATE INOER ANLEL Cotti~ms OW Employee CTD Mame} emedis | _ ere pes ils) Gimme = Cot 9) unique Tndef —_ 5) Composite TAA ex ‘\anare = Cotumn endes t= “ =o ~ Sinore Colum Inder 1S crewed based*on 4 s_ eat SP ey i ave 1 Colusa +! uae : one tate | Coturs te Syo1ex! ‘CRE ate EMOGY THDEKATVAME ON TABLE nIAME (ea NE xarneie * — Lcpente THOEX Triperl OT’ EMPLOYEE CzD) 5 You +o PROP TNOEY 2 ae ee lg Drop CAMMAND Meu Can dvop tne TN OEY. a = [deep Tuber TWverOewioy' on? : ; _la_sinaie Column IAdex 1S ke an _owdered st _Aneat heips 4ne database Pind infosmation faster. — SQL Tndex: | Fo inewease ane perfor mance OF ANY SQL QueTEN hen You Can crease SQl_ Tnoex. 2 AN THOEK IN Q daiqbase iS Nery. Similay toa Indes iA bacle mw poo. 7 a “_fow erampie if we want eneceie any SELECT QuewvTy Annem aq we can aisa ure ther t ENVER because or better perros mance. foe DMLCTNSERT, UPDATE, DELETE) Statement MOVER is Vesey Usetar in Sar: ‘le Pox eveceting “TARDE Noucan= use create | TNOEX Statement, _PNOER Can aise be unrve tiie in you appried Ley wadex ass index yan ene Ade ava You Aoning Me applying Same inde on Same. Havie, anen VA ot avowed - for Creating a-ctndex Nou can use below Syntcans j GeTATE TNDEX Trypex = Name’ oh TABLE -NAME _CColumn = name) + ——> a eo HO _enanirg Ic.neck constrains ya He ne oe + Tne -Checl< st mains! aN Leona on |b “grec se Verse PEND Eevee ~~ _ ete: a mecorAS 9 — _—_ Quer sanie ig _present under . S4S-LSE tout - ACCeS\ole to cary the Uses. I. Dual dave Nas ane dumm y ‘Columns degined wwoitn Nawehasacv) and contains sane aroco wit | wawue x, | = ISASDATE exarmpie: ! t To See ane cussent System Dare then Ney _—_||_€9 a6 Uwe neve ays pate Pyceton | x. 4y - ; i; | SELECT SNoaTE from DUAL; ery | : i ee, | ex) - Returns tne Current session ep CF UE ogged< SELECT UTD PROM “pVALS Maas |) EX: 3) - Returns ane Uoeaame of werent Wes Joqejed pen: Il | SELECT Ysek FRoMm Doal; _ a if a ENETH OL 2 LENGTHC) Fuschon \S_ wed > He . ee in ta length of sent fret 1 LENGTH Clol-Name) Stem Tadje Ye “Na, Syntax: SELECT Gxampie: SELECT LENGTH CNAME Ves Records: S) concaT oO; Concat ¢) function Te asved A Concer - two Srmina | TextRiela- Senta: SELECT CONCAT Colt » Cola) From Fable-Nam, Reampre } SELET CONCAT (Name) sirName) Fsito Trome: , ’ Scaiar uNncrian Aneer -yaiue- a) UPPER CD 2) LOWER). = Satet - 8) SoBST2¢) &y LEN ATHY ” &) Cori CAT ©) : i UPPES Os VpPERfunttien is\ used TO Converts aq Pied TO uppercase letters, * Synvaxs Servect VLeEPERCCoL-Name) Prom table Name 5 Exaropie $ Serect UPPERCName) Prom urex-TNFO 4 2) Lewes O + Lawlr Punttion iS Used +o ConverstS “field to lewercase \eitevs. SymraXt Serect LOWER CAlahamn—Name) Pom 4fasie-t 5 [Reample £ Seiecy jeower (Name) Prom Recowds 5 2) SoesTec) t Gupstec) function is used te exivach Ane crqoratkess Foorm a dexpietd- cuntox 2: SELECT SUBST ( Yolename sr aeT- LENGTH END - CENT) | eee a (Exomples Serer SvBsTieCrlame, 11 & 4 fom cecors ; iH —__——_~ Let Stasconent 3S nor Cennected in crag, i ee Leormwoare (database hame page) sjou Deed ote L Run S@l Cammand: Vine 4 S | Gerect— Uses — Fae Suet $j 6 mre Connect <5 press enters a "Serect “use® Page Puc, | * Connect + '[] maite | tis cammanc System ff Usertame System 4) password Se COMO TT -Carpemit Stare nent -h Cammane is used +o Peamenentin, Save. Any. tsansathon | inte the — darmbase . , = t cen 2 --Wheneves we need An ure -Commit ratement _— Lo kMEN Nou have te use Commir ONE We excare Commir. State meni +neo Cetpet “coli ve Commite Compigre Syorax Commit} so 2 2) RoiBace + 2 Relthatle Cammane 1G ued te Toirtoatle the meceordas. 2 Whenever ye need TO Ure aeiitbalé starement ane we Nave to ure Rewbhacte wotax + Rowpact 4, Save point - Name 4 s weneve® is ued vO Save for AeMpo Tair) pura e + Save pent Saveporn- omL oor tome is daa ANU purer |!) DOL 1S dara deeinitien : Jangqueyé language 3 = One a 2) OPL axe aiweys aro, OTL Cammands 1S Not sways Ato Commiteg Commie dd 7 " ~——— 6) DOL dasa win “not be “OME data evil be HON bare = sobatk ret : example % toh “Rcamyple + a) Creare ata) Bogert —— 2) aster ) update 8)_DwP, sant yt): perere G) TWunceere : be ope 5 | drop cammand 'S wed to Wed Ao AEE Ae dara | peveie whole Aaa as wen Met dete sanre srrucuelas table Structure 1S peemenialy: 2) WHENEVES You can ure eeneneres WE Can we JAwuncare _carnmand saneo pOwp queriy snen as a ara backend srunccue patleenct OREP coin Execure LSeit\\ @xecate TOO queries ene queries DROP FrOM So Fisst ene is ‘avop fab ie Hame-. reuse Grom 4ableplame at land Secanc-ane 1s [Greate table -tablename: S) Inside 4euncare we FInside prep twee Cannot wwe Canot Ure ene. Canditten! tohere Condition. | I &) Truncate Cammand iS | prop Cammane is slower faster than doy “Aan es Compared to Aruncare Kammand 1 Caramand 5 y Pruncese qe re dante: pene tee Grom Aan) eter. Pereuar & Prop Prom janigY toher id ze mk a 7 | Torun care . Se perere ees I) with tine ete of * fauncere!_toitin the ep _OF dereye can deere whole | Cammanel (@e CAM dee, | dora Lentive dard ae wen a. TT om, As 1) pewricenay dara. 2) iinenever! Now icon! we) tanenewer > WE "Can Use - Awunecte Camman cd shen perete Carsmand +nen ~ T I ; dea cil! ot soll bark. deka coll) Toll back. we ae we thave to UE Toll boave ' aceyemord Rei acre j Ee Deere ~ 8) Truncate 315 fasier V AS bowls +naq Aa _derere | Truncaté€ a ——| i = . | _vetete 4) Touncase 15 DOC Fauacere 15 DMC Camm ecammand S) Carnmand : 3) Cammand 3 Touncede tabre fabreMamesi entire: Delete Pm Faniellare) Weeki ceurors Delete frm _[Howretlane tohet ad zt} ; Serect CourtT (70), Cit “Mox fyortion iS used cup Wy CO have aame vale = Geng A © crasemnent | AS} segments | ‘Cunehon: ow cre AUG furcrien is uses BRAS Wen ne “) (utes ge 8 anes sane. count fuachan 1S Wed TD IVES ANE rer, ia “ieounr 9f gnar:Aebre Sereer AVG CSa001) [om qamelfaene | _ | santo _2)_ Mort o = Vowues of nev tapie. : “Sy oto + rt _ —— Sereet_tag (Serer) fre _EMPPEMO } 2 “4 min - —_ a a = at Synution is used 10. ae Ane minimum vu {for i __ _NowvesS OF 4g tnos +an'e- as 7 et -_ a —— — Syntax. Ai 4 a ee Sa censor — — .Serecr SAIN Coacany) from Emporio! a =o Lb 6) Semo - _ i= ‘Som Function is : am | 9. Punched is Used TW gwes po Ane Tero4 Sul _ of ana rome, S008. sejery Som (enaty) ). Prim rapa ons lh —Tiear quer by veawerds Tt Born pecencing and vesrenaing: : a 4 ig used te Sorin, ss Sa = ons s)onten bg_Kenevers— 3 __Serec\ 4 fmm Tabiename cence a. ex -destenging a q_ascendin’g” me devo) eS a oo 3 2) when jou need te Som the deva of aq aapie aney vou Con O@0EQ By. fe f) wish ine here of ORDE2 BY keywords me deta 19 ascending Summon) ewe. a we con semin 4 : poccuie ee : : ——— 2\Supeese sometimes ‘You need w Som ine Gant ge in_destending ender smes 4nen sou con is b, ape = Desc keyword. Sees s eee i 5) Su © med! eae umofemes fam sabietlame Usnen ee ecmerere = ASSES or Conaiiens: “Greap By Columnt Some pig onder Seren eycowrnderg ColumaNarne Kotumatiame » Omer By —!2 OScending and ene Column data 36 deScenmm — —— Syntax — * i Ascending - Nou Can exerwe -4nece Pee — i 4 frm taneName onoer py teumajan ee oS oe sum Ajo Sevect Count C4D,) | City oe Fe ak a Wescending : 9 cs : : a 1 ynaem Score tm the here _ap > seen * sg) Vike c\ause 3 Used tp yawes Comm pave sen and syorar- =name Gerect Coll» {012s Coli: FAO avie=Nan where Col Vive | Condition Display she Names ynar Comains amy jerres any wnert ele Condition / under score Gdmo we Give simes “Uodesscore wen we using Nove +0 wniie is used a0 repeestnt a = crouse SSR Se ener eee iS used tm _derenn “Mese perceniage operas = ane one om Mowe mw hPre chovecrers - ome TTT The underscore Sign “represers ane NumMbes” or enoraviersS [GOL Disrigney: Gisrement s Destinel srotement AINE dubycare Tow | Tne _sevect mmeurn gay. distiott digtigey Careewrent vanes LSuntoe - ferenin iseveer 1 Sroremenr 16 oes w agecifie Records | Dishact corumas fram) _Tabieame } | Peruning wnoie Records + y J ee ae Geireck Distinct Se fk EavM Tavretiame — between Tasacate€ ane peop PUNCatE = winen coe use Asuncasre UNE BY AN Endata eit aereted beta Net +apie tnucrue cana we can Use Wen Cawe WHEN WE USE DROP: query eeV\\ aa aeveread ane ago ahove le Steet cand we can Meh we were ———exause- Deffrence Perevee os ‘Truncate . ancl Oeret ec == || “Vruncare BP DeVere - T \) tWonen awe use 4jnuncay when We Use Delete Cammand Aner dara lcammanda whe we can Leasity deleted put netaldcere ony petticoat 1 table Stwiuve- paaee 1 and aso wwole dar t 2) Truncate idia poe |! Pevete isa .pme tT [Starement | Statement - rT (8) With Amuncare cadnet! Deva Can be ari bal - use ane whee cause witty delele Cammand we Land comecdlition lean use wnee clause [eonaty a o\Moet ¢ eet Nok FoI hack 16) Truneate 18 Faster | perere Vs S10 WEY aad | aqua qak SSO ke _Derere wooly vawre Acer _Dereve favre +abye-Mome- a _pericaiatr Records: Se eee name WHEPre d= Bi —— 409 sanqui Dara many Euiaren lanquoge — __—_te_updere existing Commonct recerds DVedare -)updare cammana is used SS BE enog ae Soret —— a We & Tasept - Taser cammond ie used __ 2) whenever you need to updare tne oo wAS in are 4 ne : apes cs et cy __pesricuay recoras _ ___ to inset _sne_ as Av _wecerdsS 4nen ou need te able ee = __*®_uSew WHERE iouse-- 18 a : ~~ : —< _—__ LL = cep een smo 0 WES Clean. ee exntar - “ SrAdta = Heleva at = ~ 1 5 —— aInsesr Tnte rapie-name voiues vedate tabve-name Set cotummn =Voue gz (watues |, Vowes 2, Vowes 3, ---- +) + WHERE Td = TO Number — T tl Exam ple ~ = [@rampre- — : = wheat Creare tanie +anié- names id number. Tisai Dame Varthay 2 (20) ss Anser into “rapie = name vaiues: @ | OFLETE - J Detete cammand iis used te | vedere UserDara ser name =iAtisn'tids 2) ipericwiar existing records. - = Se e 2) If we want to deere de woe secre [der able deva we an ea aso ose deere cammand- —— ane dove +o ett basic VS @areoite') a 4 . oe pe ak ___|3) wne jeu see oelerte srore ment ane 7 [eas monibork by wing Reubatte. Zé name oe [Te goweacte eword is used + \ Rurwire : : ei [ene data sbur Med need to unchert Duane Aurocommit chectebor- ep aiHon Language ALTER TABLE tale - Name durolype , cExamp\e — Creare tanre roble-name (0 id _Qumber Nome _varcroy2 (20) ere ON Greove —'+- or creare.o sabi DROP — YORoP Cammand +6 vLsed +o detete _ xapie dara and rable Stsuuture- Dwhen \ou we dwp Cammand ane dive ana tarie Sim is permotany _ a a deveted-. tou Cannot Canbate te dara Add ONE COMIN Like DIVisieD - syntax = 7 A\iew tale +able-name fdd Division DROP tabie _table-NamMe + Vorenay (20) 5 ay son\ aie deve “Truncate - when tou — yyunique i sed to De Pren ce | = TnouveSeeaes a1) youuRssin’ o ceturg unique wey — alore actewcot 2 a ee Rrimory Yer -_ ae = _de giao st oe a __2.one_sane_co can have maitipre UMque y key primary key canner accept ane nest een Noewues create cme nast Cpe eae ane ae a [ta wumbes unique’ teed —_————— ‘ ra umbes — ; ene name varchar2 (100) > | Unique Ken - “vornar 2i¢100 : ee -S)_vaique Kay} can airow se quit tolork | i_cit sayary Number unique _ "ey empty) voiue i T . Peay iz . ca) unique ey you'can use murrpie me | | lone are ___@ | pettrence perween yimary jeey and | uoique \eer- : | > primary jee4o - | one soote Nove anw ONE pwimory ey: | jhe juaique \ey - Lo cae bE I ene taste nove a mattipre unique key: | avoid: cos! we a)one jn last of columns we needs _ ana cannot Example = 1) Cvecue Table create tase useTnt “ta__umbes primary key Came _vorchar2 (16e) 1 comaing TLE vouues Formanon (| ~ypmmart Key 1S used 19 ; / Snes duvvicve dara 07 enyy 5 vasues cy, jane have anv) One pumory jeey a a) re Mou want 8 set primary key x multiple Cotumns insert Singe neo Hou can use rthe ane primary primary key contains uaigue _vaiwes Aabie r | Maset 4 Constraint rane we | CA Norwnat 2 Clo) =< Sarary Number _ ___| = = oo eS 95 10 | 0 IP = tewie Crecied - _2)_ansew_sne_ Records Ensew | tO USexTaTormarion vanes ¢ — 1, tamivam', 'maqar' , 10000) 5 i S - Leia” 1 Apo {fy - 1A YOU Sel the mertiete Td__Qumbes ¢ » O40 mee U8 ey tn Form a) * Rerer ‘ Pegas Pune! 100 O1P = sistem Censtraint voilorea | Means Specific wasies priman cag have omy one primary can use. ne prrenaesy au ate tev ore yale userinformaion ( chara C20), earar} dumber, Primer key (Td, Setar}, (OIP ~ wow's mnseted i opr - Data __cTypes of 9b 2-40: Create Tanie — Wyre t: sleweare tame “same name ¢ a a = who id mumbe a oe ee ge ome vena ee Nome vorcner a. (26), 2) owe ee a ra & Dije euneece {OID n> Tenie created a QL SML- para Manugeianen Language [ apes of ome e 1 ih) ingert = nse into tarie-neme wvasues 2) updore Cts | Runoie' ) + a 3) Oevere | Hows te te = — emt rrecnyd= in ane tanie - ___ ite = Treasactiom Contwl Language How +o Tern I get | Gemves | Select dnger | Be sail = itipes of ct aaa as) commire _ - 7 _serect 4 Prom) tame_name.- = ____i2} Rotthock —_2)_save_peint __ Pours! 42 seiert peti ese dod = a = Jin Sac: g e 7: 7 ~ . ae a leerect id from tanie-nome. Q. C Stan | Jt COSA Neto quer y Nanquege ft Stauct La SAE SOE querry lanquage Jo SAL NSO Standard query sanquage >, 3s ioe ee See “eve, of is pertorm database ve nea : Using s4¢ we can _ _joside +ne +apie a usin > eee) 9 Sqe we can updare tne deco _ on 4) using, _existir Sgt wecan delete tne dara iO dasa. S) using Sqc we can Feten | eetwive | aer rhe derag From tanre - Dara Detinanod Jang va ge Dara Mou pr r1On language eer _Sara convw) _ Vanquae TEL Tranyiction tenho) language Biiiiiiciiciine. -¢--..- Conv \ lanquage-

You might also like