0% found this document useful (0 votes)
29 views

SQL NOTES

SQL notes by sudeep sir
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
29 views

SQL NOTES

SQL notes by sudeep sir
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 103
J60l «OS | what is + entity 2 5 die dene anuventeeuuie ina_ushtch Lexiat ~ has Same attributes and behaves _ “| Tn_physies On entity —vePPer to any thing ____|Latbtch a bP ool as ____|- Ino database an entity is “Something laoont which we Ove stoafng the dota =| every entity till lave ome _atbrilbotes. & | Whot is @thiibube 2 __~ Ottribote ave used tn define chaxacteristte Lok enHty 1 ad - * | What ia date | Dato ie yow fact which not have any eoning on its own s we Can produc o Umeoningful Tesult offer the processing ithe data - —| Attributes define Styictnwe OF entity and | data define attributes oF entity (€g = consider bottle ig entity Capneity. pure [eolox, materi! Ove _Ottyibutes and the waives Por thot atti butes is date. | J - de ——=.0n_any data ba g_can perro ———Operation_,thege operation Ave CCRUD' Operation Cc = Create Rs Retrive OS UPdate D> Delete DBM Database manadgemen => DEMS is 4nPlwoxe Used to manage database. We peed used DAMS Meoniy for Security 10nd apthoartzotion. i To_interract with dbms' we used Quer! Hams Gtoxes the data in Files | —— [ | aed database eevee [aay nie iat ania eee = | Gar wos created in the 190 Of TOM a5 a ____woy to _inkerack nite their database System ___eniiedwali cium) Ri) oo name of Ws —iligepuel ee es A inh _ Query. Lang. uage". —_= Sequel Faced a. “fodemask violation claim fom the hawker Siddely ajrcrart Company ae to the name being _thonged to Styuctu re estaufialeialigs ngs Oe 96 Quod bk te sore = Th was then adopted by ‘the Ameni can —_ Notinnal Standard “Tnstitote in the 1980.5, — a -juihtch_led_t0. the developmaeniel ABiahieS ELSE ___ eeeicin aq —Stondiand EY a 19806 and 96s lng rove data er ae aa ni ee ndawd +o become Ane — Ty {| | I 1 4 Ena ante eae f 4 _>¥ [Relational Model + rte foe 01904 developed by Ef Codd th ee ae eh la hathing b ass oF rites e Q — fens of nt yWles i) Data Should be Gtored in tables ii) Dota entered into a coll ee 6 ii) In a table, mM Ont Then two things & )_data c if ue ome ion dye 08 Follows : 2) conatraints iv) Ip a ‘elotinn hetween Ocrording do 6:6. thy Poxefan Koy - & Rygms t- Relationa =] PRn8me is 4 veld 1 | Any pm a Rogms oft (onal da+tohase AATADASe Systero ae tables 4h Codd We can do tt b _pyimar Database Manage ‘ ave 3 Rows Stores the dato into tabla. Tables are 5 —1als bo _Colled 05 welatron O01 Schema. ___ 13 | To tnterane with a 2pM4 we use SAL (Strvchred Query language) aa eog= S| _ > 208Ms [Ct | (deer I neta) Wa le I 30 || T — I | | o [DBMS RDBMS [Cmongone » ___Coracles MySOL, Sat, — Cassandra) ; Pan) { y V | Collection. Tables | wv Documents Rows | Ye y Rey = value i Ter+ values Dato stored tp JSON Files ¥y Stati done _hovizontaliy \@ +0 e¥tend the Sevver Multiole Server can be: added - | rae _% [Pato types Data type, Ate Some predefined Wey y used to specify what Hind OF value ___lhe Stored Into & Particulas Memory - __ 4 | Tijpes oni5 |) Number | 9) CHAR | 3) VARCHAR] VARCHAR |e) Dare |_s) lorpe objects iL | Example SE I Tea I ‘q-2) ‘gab LNs shee) il oe Hel t C98" |} [There are a to Op 6srar C rHodoy Al) Chav watuer must be | Gngie. “gute. ey a _|8yntox |S icHAR (é1zer _=lwhtle using CHAR” a4 0 datatype pybuiding o __\bize ts mandatow = By vsing CHAR as_ a _datotype jo UpiRO OMe Chornakeh 3 Oe = Chor Pottows fired length mammary. aleatinn— Bx _,cHee (8) aa ~Ottupred Hastage oe eae “aI VARCHAR 3] vaRtiAg 2 Sameo6 clas. but_only-di Fhe sence iy VARCHAR Po lows Variable length _-cllteco+ioo e free memory dy = VARCHAR (s) poemnen — "euped " pelarcd =a Memory memory | we _achefve ee cflichenty us; = lAsart American gtandard code _ for in Foren ge Say Tokerchange) => [Fre ic naive aon cha ee ee eS ———__. Una ra Cte oy @O%e 6 pnversation | binavy fprmat - ah = | we can check ASGr Valor pF ing Ascii We) €-9- Tn Bar fing ng ASQE value => Select Ascent ('AY) Crom Dua%s = Agar On’) Ge — |Sevect Asat A") Pron pyar Pacer Co) Por © = 6u 2 g <9 % Number 2 es = i ed tO ove 1 De} O s(n a Column. Syota' Numbex CPRECTSTON» [ Scald ; Note == Cx(8q0 ar beaeket) In Suntox 6 OH al nN (512) = : 4321-1239 N(43) | SS lobo > NCY) cage 2 3= Pas | 2-9 poo > N(3.3) 7 Hl a> NC2) 9278 > NC 44) (eae diame he 6 00012 > NLOS) - 7001003 >. Ni (ou S)s aiieesor al 00123 > Nas) -0988 2 oN (305) = DARE gas . SIF ne eed sto latare dota type value p> _Ovacte spect Pied formats - j Formats _*- @_po=seu=43 __@ PD “moni 2-9 s- 01 — Ton-24 25 -ApR- ed “Thva uid = = ov | tan|24 ar |i2l2005 louvlon — All data type va 2 must be e@Ncloseg ol thin Single Quote % | LARGE pBrecta <= | = i) Binary lorae objects = i eS id d to Store biaary Value of Piles 7 ae t+ MPS sy Mpy Also called Gs Blog Ty — By _using Blop we con stove Ffle upto | Gob. Li Characters arge bye ¢loB):~ J eo P= SED hicno are hauling CHG valr be yas eg a Oey. deb, fova htm) - sh S11) LoB e Can Share File voto AB | sp | CONSTRAINTS 3- ce es is used fox @rt1a uaGudadron es OP ConatraroH [OW NT Oueie bev cuties ube il _|@ Notnole_ SUD ak ___|@ Check ____|@_ Primaky key -& PORETON KEY _ — “Niue 1 Tk 15 used to vefeck duplicate a eee — Polum p — ———_____—_ a esau & Be tp tect nol a— tno column. Be \ £ a Qiong with a canditfon- aera cea esc wo sue ll = Student — table_ 8 -Tp S_Nome Borage ah 6 i) |— Date heh 12) yc (20) N(3) i a j Not Nol! a yea cunts ize or Os 26 ae | (we | PRIMARY Pee se Th Is used Fora pee given for i fox uni ff} De is a constyaint: j =r $40 Combination OF unigue and hot nul tn a tele We Can have only: 4 prima: ; a — 5 | ) x =< OS Sha. primary key Column dinate and n ———Valuts wt) not be actepted. t * PORETON key = Tt is used to ectablisb connection he Ween | Multiple tables - Pe S-id 3 name Gage 8-can Gb itd i N(2) vc(90) NGS) NCio) «] 10] oe One: Sales a: (02 y 2 =---. ‘ J Course py j iG! “e C.nome dux Kole Pp 1oo i | Sub / Ph 9 s 1G td Sb. name Sb cade j el A Ar i: 8 Bo | =| Foreign Key vit a fnnetint 7 = -ta_a_ta ye CO ave Multiple Poveron| I Key columns ~ SSE is Not 4 Combination n e. Ano) nok nou. | | sal EST Ore GN Key | Column, duntica and hull Maloty are Accepted. : = foreign -K Column t% a Pk ent ‘ Prono ae ta bie. Sa, Foreign column values ove. onle Tie Phey_are_puesent init oie —{Key column. a ie ad = _ | Command 40-¢ heck _connecte Bais apm RR a eae a |e user {Stn oe ee | a Rens —cleay the Scxeen 23> ——— => | Gar > Cl SCR 5 SE % Jo Check tables present 1D databases = | 6m > Setect % fanm TABs resp -outas eric Ce 8 —— __# | To Check ex pckaunis ovezene Sin database > /Spr> SELect ® Prom AU = USERS; what ts Sar 2 = stand fos Structured Query language Sal > | 6Ql is used Fox indesacting auith ROMs System: | Sok tus 0%. = [sar 14 a domain Speoific languoge Ew) tve in Nature - i = Saris Case wengitive but data entered Tinto one table 44 Case gensitive: _— 3 lBomatn. Sane i la age 4 [Wheve dre the Jang oe Sai Fox 0 eoffhc neo Apay om that we fe ee Onuwhere Else - ex: HOM, GSSrS QE __ +t "Trnpe a lanavaoe + Speer es é a Nt Loo tt by treating Function [procedures f¥ > Tova, Python” , PHP, C++ a Dectora tive { te Lupe of ~ prog ramming ! Which wir net pect tied | tee one me dake case pith dh l Sar. = || Statem ent i | Det Coata Query (an quage )— Foy. of SQ. _ 2.1) C Data Derrnotio anauage 3. DMt ( Data Manjpulation lang uv 4 Det C Data Control | d z Tel ( pete ontro! [anguage) eds 1 Dat Cate Overy language it is used ft adele. pine — Linside ie sao —coromand — i) Select Ip) Profection Pe tiy ii) Selection ys t Totns aoa 36 ug lay clea Console [Select clause Cannok woyk alane d eet LN Oo able a t- ~leoxk tusn Clauses! Dre oyequived. 1) Psogection 2 “Tk 1g prowss of vebrieving date Ay Selecting Column Name SS ee ee [Setect -& / (duTINcT] eeeAn (ol-name /capreision | OPtionate-[TAs) ALTAS | [fpom Taste Name 5 a —t_Conomand to fnexeaté (7 Stt—Lints Teer LINES Size, PAwES Size eit LENES Gize y _comber = Set Panes Sire 5 L3 numbe& —_ A Aor Cwatte Guquenn sien —z ‘Aut the data dept table [=> SELECT © Pyam depts JU AQTN All “the date piaenk in SES elec’ A yom lemipase LWARTD employee nam Db dtig naton & thei al ay > | Setect $ Prem ename, Erom Emp Jobdaignatian Salady = Eton any Guliy, __ aie Curt Ond then efter AS HON 0/0 ptf make the chang: ind." neo Bau { Land then close ft sa . will_2 es the edfJed queey used _fouwer Command to get las k_quvekay opus. peti gprs C4) 2 = Set ae vie previous — qulanip ule Ce dst — foxard slash C/). Le a onl _ot WABTD —empiayte nurob.t.. Hivedate. 2 coremisuone i Q) @mmpioyess 2 ] ieee rs ie ie a . | | [ nig 1 WAQTD Dept name. —Ond_4 éuy locaton. | Select Dept n aces escent ———__Proim Dept + want) pboletignation -that ate presen ——_ bmp table iene St yn Era pe & DiIeTine +r Tt i4 used to vemove dupivote Value Bevo © SAG UIES eet / ee SUE aie: vl ad M4tinet. dyOR aueeiacns b iv al I Prom EMP. susan he tL i 16 Il a =| Distinct clavse as +0 he seen an a flask Argument HOLA pee SIC ciiae —lTn Nisinet Clouse we have to walk cp ___ | names = = OM Write Mulbiove Olumns Name $n AtvsHact Clore Se eh Clavse is having mutt'ple_¢ e si ae “then if alu the values du! | Necomd wilt be veyectol.— __—[f--“Tob a ee ! (ono Tob Sa) I & \O.60, x 8 {poo ; IF eal $00 A 3000_ C 13.00 Hoslay %) Eypression 9 /Wwaatp sian names along with Q - Sa Losey 8 ark eee Ug | ___ >| Select _Ename » Say*i2 —___|_ from emp 3 = 6 BOT) Name. Tob, Salaty and 10% ——Saloxy Por aij the employee = Select enome, job. Salary 3 a1+saing Prom mp 3 ! ] & WABTI nome, Toh and 20 7/- deductday Sl Seicee ename, Tob Sal _, 8a1= Sal# og Pyom emp 5 i ee yore Mo i bmbination o Opirainys | Ano Operands = SE) elect Clauge ema, iny a ~ Expres (On A Px1O1ESS 10O eee? ps iT _ he come column name is la is not ¥erommended to have om le po. 04 0 plump name tn o OTT lt hte. lustag ALTAS bie ALIAS Name Charocterisite. _=/ AlTAS Nome has +p be one Single str ere fit containing Moulkiple words le ca — — | Sepaxate them Ww hilt using —undetscore C—)— __ Saviors Apnea ——=Tihiie_paoviling amtbaS mame Osing BS Beam __ | ig optional 6.4 SALE IO Annual Sal = Tf AITAS Mame Must have One space In_ Lbetioeen then we must enclose entie ALIAS s ___| Name tn double ead-qu ye II ed Sole iz “Annual gar" se Eh lecrron ys ree. process OF ret cievina eddies p> PY ‘column (4 welt As 10025 Xe Suntevx j “Belect x /(OtstrNct] Colcname [Erpresion __| Prom ‘Table = name Where 4 Friter - Condi ton. COl_name Opetortoy vatue DEPEND ins Th details OF employe orking irid => Sete Srepremetename Select 2 | From emp i Il Where dept no- 10 ; Erem e a €opne.| namie! D No - ian ue (0 feos D fee eH sie = [Order oF execution | \)_ Brom _2)| where clause —» 4 “ey bull cme ___ || Seve ck ictguet Sagoo —byigroup _.Q WARTD _detotls oF” a Selec’ Te i Prom é ’ where foniglinienienee: Ee detalls of employes hired Ofte. aps) 148) of yA Ww S lect & i | Pom where hired = % 2M acy qe Seletx Prom emp ’ Unere hiyedate> | © 2-Apy agit val ae @ nen details oP etepla ~ i thon 2000 a =| Select # a Prom emp — Where Sa) 22000 Q WaaTp Cetsils Of employer GYorking ae Clery. ga Select * From emp + CUinere j0b = ' Clerk? $ =e | OPERATORS e Oved ine Wwe perform sore action / Pack a > Types OF OPetators Am NL ARTTHMETIC OPrratnys (+, -~ 17, a) 2)| RELATT ONAL Operators C4 >, 22, 52) bl COMPARISON OPerators Ce J=. 0 <>) t Conca TENE TION operators 1) H ‘sll Lomical OPerajors I)AND, sl a MOR 5 Citi) Nom wae ' 61.648 60et8 operas tied i aa “FH specie: operates be j “IN. [Nor LN N rs =i eet “BETWEEN | NOT BETWEEN _ ee eee (ig) rs Nut / 13 Not NOU ad aleve Not Me SI Congr _oeeae ae ae SEE sE eee aio multiple Strings toyethe | Into One aos le Siaiph. ae __=|ushile coneazenation opetator we CON sain aig string See [€. gus Geleot: Enome Il empno. As“ Password’ | from_em p = I fox using SPace |) eS Seica Se mame me 2mp No. As” Prom) _ennp = (LOGICAL OPERATORS I (pgical operators are used whenever we ___lhave to cheek muttipl dlttio — |) AND Operators i= Tt ts used when we , Lhove multiple condition ond we hove do = lati of chem. | a thy Op ‘pperiiors 3- TE he ue Wave aah St eae tI =e |i co) = M_ valves PAOIbY = 1S5 Ml => pip: |v cor =" \welves = AND deena ton Anal I — Be Nee ae @ (waa. desats oP thet manager ov _Saledrndn Serene SS Sauer _____ | Po MP wohere job 2 “Salesman 67 Job = ‘manager 4 | waaty debaila of ials- ap manager—€ depo M010. a + 4A ee ee E. | From EMP fee Tob = ‘manager and! Pig noe 0, a WAQTD — delniig of empl pyee_woaking 2s — — Salesman in oe nee ——— > |[Seiect * | From tmp ; wheve oh = ‘Salesman and. (dep np.=26 or | dep no>30 WAGID _fletasls of emnpleyen.\ laine abtee. 8 0 * land: lo tfore® aa | HD aiden 8] => |Select # han HD = 301=Tan-22, _ fom emp “where hive after >'31-dee-$ 1 and Dane we HivedutZ ‘0! Jun Hp 4-31 -~Oer-g6 ic 8 Waar détails oF dhe _omplay ee torts — cheek hol oY Analyst hive ce ening Salaxy Moye than (fo t 7 ——_ 5 Eh ere Grae cen om | 7 a Jbb= + tual ANSE hive dat, Sai 4amia php sae 5) = SQA| >15003s — 8 waetn detoi I ; ———.& Sutesman _ “3 nee ck i: Grom em p 7 Obie Yemeni haa eA qian nanan Tob = ‘Manage a OV “SOb = President’ ; iSelect 1fions en p ; | whare. Sob TN Csal-e man’, "manager", ¢ 1 §WASTD dedais ab dhe 2mpinyet workin |clepd WO: 20 ey 95 and earning by Q p_ 106 t oe Wer lk! Oy Onalyst - ieee FEOM PM p a heve £; Ement d= (26,20) and Gal > te00 Ghd job nt inlaw’, anatysi) “t Specral Operators —__— it > This ane the opexatars _ used to-handte. a HALO es Ot es ts ntannal operators ¢—~— _laxthtinerte _ compart.son Ona velatfonal) ___ Cannot handle Se One Valve And {Ris at va Cie ee Th ts Used 40 _Campate mun vag — Tens. .. __fe 2 _Col=name tp _/noTw (vol \,Val2.. vals a Bd eee the Omplayee ho ving name 0d Martin Blake, » Ward - Tart 22 and DOH a Sales re one ae pea analyst and eatoin A a o |j900 los than S000 and ee 1992. Swlect & | Bro. , Where 2~Sa1eman’ 01 Tob>" analyst’ oF JOb= ‘manag and/Sat >!000% AND | Hfvecl ate Select + co. | Brom emp E at Where ename int martin’, Blake’ BS (ward a) u —_ AND Tob fn C “salesman? Te + eae Or mes Mo Clos —____ AN) Sai 51b00 And galesooo ang & Hfredar. >= 'o |= ga D~§ SS and hisedake. 1 : 2) BETWEEN / Not BETWEEN Fit is used +0 Work with sane Clues, 8 pptoo = Gp) name between not b set “oO, “low eb va Ant DOE We ee : Son VEC OTA, SPEEA ete ct name —aa k Lyi HORS 1 . fipm emf 2 ae EAN DLE: J where al betineep=l00 andi Sooo aut — | IWiPOTD) detatla OF the emoinyer Wire between dhe year 1930 +0 1982 Sul Steet + 3 Prom emp Where Hivedote Between 1480 AND 1982 ‘Ol Tan 1980" ANO '3 1-0 LWARTD Name “ond dalany- of dhe employe sh axe Coming 3 digit Soldry oh-theSemployee etal Select a Pxyom_¢ E een Betupen 100 ANID 9995 3 [waatn etoile of the employee (ho ote _——|nbt_eaokning commission [tes ¢ than S00 _ and more> than tooo _ > [Beiect ar | from emp ; __wheve “Commission not Between S00 cd [p00 \ __#) Chorarterfotte OF Nut \). Nut) does ont ‘vepregent 6 OF empty Q. li doe 3. Null is a cend ehd No_any memory addyeas Ea u. n ‘ © Jul | yeault - to Null i4Sere. S- we —cONl_npe €qynit to Nut) “WwppTD dette OP: dhe is aa ate man earning any 7imiausten Coal i eos x

You might also like