0% found this document useful (0 votes)
2K views

Kanna Babu (SQL Server)

Uploaded by

deep kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
2K views

Kanna Babu (SQL Server)

Uploaded by

deep kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 94
SOL SERVER Class notes By Mr. Kanna Babu sir Ames is €§ 9951596199 ang oy E yo, | pa YS altont End cappliccutom: The appreaion whew exccictly VER sete WR A fhe user will THtAaC Te cauled Kentemcl appiic ation FE can be Aevcloped by fremtencitoots thee lexx PhP, -net, Jawa Jext grout inbox, duch1S CHC% | Back end | Appicad tcp, Tre APPNC AFTON cobene escachy user data 1% maniained ood srosecle us te. can be developed by backhand boos hee MSSGL ScHVEr, OVACIES FIysAL, EXCEL, ECCESS, H2K cher ,MSBT, testing tcolSs —SglsSovm. Joud— osacie. 5 PHP = MYSQL Doyabase is systamadtc CovlectTon OF deka. since the clara ty the daiatoae je oxgonised. th roukes We dala maragemenr €o2y- Ce Satypad mobile Shope, FAYSCI!, UOVOSHY HOBME HS adara babe management SYSIom- fo manage dara bast. Be Te a sok waNe Uwbrch Te Urea Gezcce, Access, Fes P20- #ADENS- er fs a selakonal Ada base eanage een legstenn cohith 1S used to monoge' DB- BE SAUSE WD HES OVE mysQb x SQL3- is cstsucitined Gunny larguage car—> Gequel > Structured english qu.ers language CQL fe a language wobich ped tO Comrounicate ith dovabaag, je 1 ae eont tO store the dca OF FAP pAlate - IE date we bee x{Pn dora base #e dato ostil te troved in the fostm of tabe. to Use sql @estar te table 2 4 ble is a datal obec wHIchie used 10 Stoxe line clato. An the form of wt management be studio, SQL SERVER 2012 Seaver, LPS i Devlaboge Engine BErut > Mame + Corppury Same/. | Zpaddrts s. fea then Hication ; B@L Senven Autentcahorn La + [sa fob Sod i _S Sorc tyPe>ODota bose engine © Repesting smvfccs @UNGWOAAHOO BoeTecy 2 @eralysrs Cenvicta. -s Business Uotrgence Me ie: Ihe higheoud aotihosttres TR Companies uke CEO, ProjecrNanags, | ef Por deSSTCN pearing UC Uwe ac 1S, S5ag, S525 PPssts re uned to “aollect Cota form OascSouuce. ez!- nom, Douatese| Leeses Ts aned to arnlyst the dace SSSAS Is Uuned 10 LED the -dater, Reporting fool eouleck ~ QQUY se Repoxtting \ srs sss eses AS A SNed PAD ewUO Pt, wwe ane USTAY sp dara base ab date * Re ce a tose. ay Hee we PoLe tO menticen « ‘the © Senucn Name’. Meurme of THE Comput CHEW -EqYL Senve leortunevn * wus trecatied. [Sous PAINE = COWMMPUIT, Name] BPaddness ef lee cu HOS, euiberrcat fon: 2 TS a process oF Checking YER excdontrals. lune cscdentials ppeans uot» rane -end ossoand ANY Uren -eoho TS FAMING Uresmame ard ptuoorxd Re AUCH -aD Ruihen ticarcd Us tr. eee Cos COMMECE LEO Sqlecmoem GeUabOBE TH Fed cemnysS wind tus PUtPEN! Cas ey SSASeHUE) eu heeTCOHOD when pts we ane conve city | gioerwer sdotakse Using -cindows - nie Tt TS mot ~wequised EG give Urea rane pos word: becouse by gefoud ‘you coe the valid -Usen of wirdews 0. S. Lo when even we Connect bo “Sqicesvt> data base Wing -sqigenver - RUtpent*CaArieNn fue HOKE ES eninn MUProme and passan%d ¢ : r pote defor eseiname co sa and passacesd fe abe. * } Dora bose = te systarptre, ellection of daja. @Predefined dosabare Boer cefined dota hae. OPsede fined dajabast> Te dajabase thar WEA fostalled when we Insial eqGimMs THOSE databases cow cauied pse-defrned GD vende firet sete Dmastens Te conpigmarfon sereings thar ane yequhed to wan sql sesucr managemenr studio are Qwellabte In mragitn database. ee C7 Te maintalng seven name, ALuUEPHCOHOM -petatis Tike Unemnamne Pmpsuerd C4. i } a > Rr 1S Akways vecommended to metiniain 4 seperate ' copy OF KHAsStendatabase fp - sqLscmuer mg. a @ Mode; Caratase.f6 O teropiate fs AL the Other g dota bases . Iauohen etn ewe GW CLASHING wronderined dratose & ben (bE conFenrs oF the medel datetore yop wi be COPYed nig Usendefined aaictbose, @iTemdbi-w © aed to pe sime tenpporouuy tables Aro Stored pwredures. @|Msve ver ss ured tO ecedutes TORS ard alents. x lUsenderined dounbage:. the database aos cems cxcoteg deperdirg on the usc deLthement Cre caMed ag WARIO ETTER greyciubasl > 7 tcenguase_cormapands, these ame uscd 4 Calc datihee os data By cz pot ome ORt FE aa iC pate. defer ¥oo a Drop, cxcare, PUTA * THUNCOLE conta S upore ,ducre qos Pata setrtre Landis select, y ecune ETE Tel Teansadion OFFS Commit, sollsck, AG Bang bet > PEvoke ,Q7ONF Dasa COMtro 1 targuage Lesngucige el Goal "EEL “Te feel ae SEIECE — update coment ean ~ delere Tou back C ewoKe ata Bent 2OLe Porn ( paccoced © deny ao We | DCL. Coata Cooke! teung Lage Cor ODL: Dad. deFircdton language commands Rese commands Ge ured tO create @ create database datatauge @b§ccis IKE ,Keb (es , VIDWS, SYMOKYMS, -ciowed Proce dune & EHC @ CAI AME US Coloumn for the SCSiIng - table @ Remove TE ColoumN FOO thre ‘ate I mop te Tame oF ddGtatygebase ac, © reodify iE database objec t- Bote nanieulotis language : commas. COnhs GO Tene Gorman watt come CTH dasa: OMese commands call - & Trseniing WE -secosds TH the table deleting the wco5 de -from ihe tCbIC. updaic the Goda -wilbin the tobit- #| DoRE- Pua Rebeka - jarguage coramands. Leihese creds Ge Ured to vebrewve dasa FeOrh fre dorabase oes fke tobita, Vics , syro cymes ac det: ToanscaHon COPE! reEMDQUage comprrands, temese ome cow uscd tO pirferm Hhansacd- ead) ‘Omese foremads am used to geanting and deny ig the pormissfon (Syntace: fos ceeating dasc. base. fevcare cbuabase datatase came 7] ex) crecuie database Saryo. Hoo 10 veo Ihe ereate database Goto view —srobject Exp lesen 4 seavcarame Compute rcuse’) + DAFAEASES srendyot \saptor.. Sp —heipdb data tase rare | co sp-heipdb saya woken we eccesre FHE abour qurrey TE wT!) lwepiy tre frfesmctiom Tb 'the foun oF dotabose rom €s ids tk, SLONEn,~. Deworite A quany 16 werame the databasc. Byotox: Sy zerharabdarctoxt nage ot [Se_seramedd Soiddatate. senamé, ‘newdaiatos’ > uo cuz sp.scnamedb Ssiatya? ,“catyod® G&) SP —veramedb sorya, sathyadb . @lovite a gq’ tO drop the daserbose - Sgro Be dw de drop doiarcse database rome} leks drop datakse Satua Gpencuicss ~ eee An opercuos is Used 49 Ferforr openc HON 4WO os more CPrends. . expression 7s the @rn bination of two &) MO OPENS OL! 24BxE oo DIFPENEN SPocos Tm SYL_Senven Oorithersa1e apernatgoms -> +,-.%,7 sh Qlogicol operGtesS —» GF > @ PetaHioras OpormuerS—» <,>, <= I@erring SpenctiowS 5 WE» COr"iKe - lorange operators > bemveen, mer bebweSP / #| DAI MEATS OpeMatorS? AN ped to PO Rann oT | AAIETONS, SabhackToo, Must piiceutton, divT sion. wohen even voc AL Bo UTNg ap expres STON woe Fave to solve bowed on primtiy of 1 eptnator - ee @ wg 10 AiSpidy we Infosmaston oF the datos tay 1c} 2c or @ipsosiry — *; rs @piotty 3 +,- eriowiy > = Jest giee eoquotrent ea. Sia =! \+. 2 ewil give BEMAINIC)? ext Slese2 HBS 46- C/5 + 3x9 2-3HS -F/qt Ya- 23 | “e Tt 4 n1S46- 1+ BaF 2-15-90 +0-0 | +6-14z) 7 as Poe ETP mumcnatos & fre queitent 15 So) ard secmarndsen + sg an deromeratoy Heh : 2 TS MURECTRHON + 2/5 —O R21 -1gy Ya -0 ani-o By. 2-3 OB Z—34 YS- 34-3 FSG oy a-SkB eB IT AWS B-UBIS ES ee pS S/S 3 . ot thing ax Gow THPUTNG Psa keybodad dara dora is Mmeantrglecs. eX wl, antl, 2000 wrod 1S TH FowsrnastOaN io precessed dare ylirosmmaton 1S recaning POM AHO? lexs peril soucry 1 2000 x? one HOGaCLTONDING, warquages coc wil! rand te PECL OF HUD SCABOMS X occupy ISS rHemMOrY Compared 40 — pare will Fos MoKA) Easy tO acccsS the data {oota types \ chonation piprorus — they @troyint-1 Gren int-Q Odectroal -q Qeigint-€ @tioare © Hureesic-F @wros is the difference betcoren chow, cba siootho, IShanCsorne size.) + Me sre oF chan i Pixed- when exc we declann Chan Ceo therm So chanac OF SITE Chermowy (S etoccyed , 1 Wl Stowe -@ly Uchomattens of dota then be “2emmnarning & Uc chanact®rs Of memory iS wasted: feet te <5] = COPBTE (HE MEY « vanchorCsome srre)!- The’ srz¢ of vanchen fe Ot FxEq Cyuinfabie tg th) echcpevo, coc declare yarchosa) memory iS br tf Sicre chan ef daia then coches oT attocare ani Yy chasecting of DEMETY «0 he vervesioing prenery 6 rot ousted - THE NeCETMU e026 GP Chanc ard varchar 7S 8006 chamacttrs , B Uning Ch@n ard vanchan Wwe CLonot “Bore WITHPAHTSMe fanguages dara TEE ehainese, jJopaneses exc. Tne et HchanCsi®Ed!-The SRE ef Mchan-TS fred. it 7s acd tO STEVE ANY Inicmnation languages dara eaume tice vaamchan . wine peLaT MM SPIE OF Mehay ard mvanchan 6 $1200 - Table’. Table 1s daiabase object cobich 16 used 40 lefose- the datcr in the fowrm oF mS é& colms. CUES, f Gystae defined) Curmdcfined) Cempacay *ThE SE tabies Ane amiladie QukOommatTcauly, tthe oS instal SL Sserven management Studio. HME tabies thas WO eneated by the Untn deperdiay On the Unen requursemmenrt anc catied as User [defined tabies : SyNtatczcate table tabiemame Cemloum name ,dolatys} Blom namedatalys) koeak fife deteber table eM) locate database sey ce Ase. Sathya. bk exeade tabie€ em ployee Cero,tPt. enarn€ ,vanchancsD Salany money, dob, doe, ermaii id vanchasCso) | aRcreate database sbudenr une student eseare tabie£ student(ane ibt, enarse vaox hang age srrowir, acid sess Concho’ ODF Phone , bigint) i % cag, tO VicLD the Information of oO table : gpiox'. fog, Fnsene THO ernptoyee WRChAHCEO?, SAl Ory PHO! NOUS CIOL, Sant), 2ZOOS) yrtax 9: instar TOtO tablename Cclltret) vases C vou Wer] ex ane} INote-Te We want LoTOSert EpecrHe vecords 7m He table une tole & Ure Gh yet -2 SHNIOE S)- insent WO tgpyiemame @iceumn iret) a oes Ccuuastet) | ener aur : | SUSE Vatuetiet) | unional) verses Cratoet3st) | select (valueltst) nahn iQe Insend ite. crnployee Tena, enarre, clergy) getect V. acc, 20000 puunton as [serec 2,6 Bbb?, 2CCCO uotenau jectect &, feec”, ROCCO - @ Eyre Ye INSer anto tablename Gane) | waluas Cvaue tet) , valuts WicusttSt2)> | vA UaCvalus MSt 3) ext losent Feto eropayge Cero » eraume {zt as the Condition is tue Cb the xe cords lone ex displayed wisyntac to dreplay epecrfrc records sore the tabLe? satct Column), Coioum 2 ,. - wag bo display ername and salou, From eroployee tObie? Seiect CNAMe, caltry Poe the Psonr tGbic Mere. erp leg ce JOpENatrOrS '- [Oo taddit lp % ysubte—? cubroack @ ¥=Mal rt PHONED - @ Create @ table colt rome sroders ceil) Colas TS > “SPO, SNAHE, ry 9OZs OB - epee ‘table bay tecele i, (te) MH. oeHR_ om, TNT, p insent TOO student value Cio fans” leerect * esOrD student) M2 i, mir) qo, 10, F0) student t ‘Csnesio Fs erame vere ho} (Sacct *,ProraMmitmrtMs, Gs “Total from studenh) . b @orwrea quewy to ATSPIAY te ESI) rHankS oPaninr S Cseect Mr, 88 “TOECU? fromm ‘Student bere Sname. 2Sanil?) wag todispiay student ditals along wollh tory fIAKS anch PSECentage OF Marks, SAECT Fas Mit M2 +m, OS Hota!) Crit HMs/20 ae Sy? Pom Student: Cette CL tobe with pare book Cuith coloums bids Drames qty, pice. Cvecte tabie book C bid int, bname, wancharCa), Qty Tot, -esce reoney) {@) toarsptny He poor cletosts long Goth 1oray bill gelect * (Quan qty * pice) aS trotal bil From book, @2to displ the patce OF CH-net. —|6elect pice Fromm book whene brame = “cH per” O@ceade atabie with coloums enc, ename and bsat Cseare table ernployee( eno INt, encime vancharlad), S bsal money) ID to chicpiay EMpcyee dSpiery da, bea, torcy say ectect ® ,Cdo-2* BSA) ab Ga? Prom employee. geect *® ,Co-4x bs) as CRra? fsOMm employee elect ¥, Cbs HO. 26k bScu) HOYX bSAU)) Fron -eropleyee . t *®, Corxbsod ab © PO’, G4 *bSaI OS “Heo, Cosau + Co-2% bSau) + Cor ‘bsal) as, Crotalecy? gxorn employee. Guorie a e to dispioy employee Asoplay derors cotose Caleny 7 2OOTR Com pewiisioo eetmators < 1e65 thon i > gveaten than p= guearos than oF egUcd | gelect * PxOrm -ermployee eohere Bajany > 2009- i : } ke = keSS Han 6 equa) @ @ to dicplay emp detarrS Whose salary 4= 2006 euect * prom -ernplee «who CajAay,= 0c6- @lecag, to Alsplay eme pames cohOee sory greaten tran 250002 sect * xo employee conerne eolasy y= 2000) @ wag to display employ ce detcuic, whose lege TS > 237 seicch * Frorn employee Cohera age >%3 bogtcod OPECHOX - ancl 9 OF Trese SPCHators Goo unecl 10 Commpane Tw oO MDFE Cond tTANS - q andl Or na g T FoF T T $ T asee to disptay Erp detas|g- who ang cooing lor To Th depantroens loz fard whose age >20 fod aks bow scect- * Pore “employee coksse dram = ¢ and age>20 % display empkyee ewrese age FF ESS Hein 22 and gage «Ag SAtory > 20000) Serect * Frorn empleyee whSSe age < 23 Onc salery > 2c00o = P/p» ajay lo0e to display empoyee dttaris coring 1O Tt depantmme nr Or whose. agg is > 29 SeIECt > Porn Ermployee CohS8% drome FP Or AGS +22 Clips aw the dala. IC OpenctorS=- betcceery and notbeiceten, COR todeEplay ernployce cletatie whose cage hetcocen 'S ond 25s. ISLECE *® Prony eroployee cohene age teHocen, Band eC IG too Beptay eropleyec Aetaglc ushose age vot between ig ard 2s ecitch ¥ POM eErnployee cohbene YE Mo} betcory| (e ord 2s. woe to clisplay crnployec detains eohose coderuy FAMgE between 20000 d 22000 ectech ¥* Peorn employee cormse Satng bi 2OGO aanct 22600 ye SWING OPCAUORS s Hee , @& Mot The | Ike Openttcr is wned fo display the tect ina spodte_ ©] te dispreuy employee datarig CHOSE Mame @ to dispnay ernproyec details whose NAarmne a] elect * pucnn ennpbyee where erorme We alto cigplay -<™mP deransg whose rane rer pattean. Ae ‘stants oltha VO srr ends ‘ett any ‘StAantS wikn an KsOy> TA bepweem Sringy geanch fos a atants -cofth az geitct® prone emdoyee whtrne ename ke ¢ Ok? Staats Cott Q Ord Whose -alary > 290007 “Cre? arch eceny > 25000 ants with 8 and -cprese sOsy> 22500) cerect ¥ Pvonn -eroplouce - LOHtRe EMCUME not Iee <8 te? Orel Salery> 27BOCO- Canetraints conereal ors oon utd boceppyy. COMBIEIOD an dlata base GHECES ake tcrb) ea. Diffenent types oF coms ey Qo ———— feu eomerscdnts BNO NW COrsehroagnts goParnany eoner wats YUOTQ|U2 KEY CONSTANTS Is. Fovergn Key -ConstsarntS Ie-Compeste pefrecouy Constsciints A Default COSTWGINIS @-carctidare ey Conehafnt uA Checked constyaint Te a & & J@NOL Constxaint : Ce CON opply the Crerrarny Ab ihe time OF Crecing tre tabie G) Aficm Crating] bbe tabie. eShen Wwe apply MULL Constraint op the COlouMHn ther tay toleuwn oill allow NW valuLs. 2Ey default phem Wwe Ano CeEOHing a babie then nut dorsraint ill be applted on evouy coloumr SUNIL foe appling OU lonststint at the Ve OF Creating the tabte . Eu! -esecue table bablerareCcolmame datatype Not DULL Constraint: RR RE MOF MU ConStscunt CoFl) not exccepe rut HWS when even we “pplyirg not nut COPARATNE ONO ColeMmD then that Coleus cot accepe mul uclueD- al ayn: Create tabe bablerame Ceolmarmedatatype het Colrasn edaratype not rus) caeate: table erapCeEnO Tor rot nul, cname anche, f Co}. Salers mony! on fn the above table - table anp dad constscynt PK- EPO ~ "AHO primacy ‘keyCro) PUPIOA FO DPC Nhe PV MOAY Key coNsiainty | Ate) HIE table mame drop consraint cons wai OrMaMe . ONG UL “key ComBtramns - f GNIQus Key Constsarnts ait mot accept Bipiicate vo Lous Aa: Unique: Key COnsteaint Goll accep} mul Udlus ff je Cee ecu apply FOOPE Hoan One GOTGua Kes Coretvaint ona single eablie Weunique ey COPEtvaTot eon Mor accept a nul yoluss become fb UI Pot accept ouplicate valuas. fit leyntabke-fes umqut key cobstearst at the Het of cecating He tabic 4 auien cxcate table tabierame Ccoimame datotype | Unigue, colnanne dautcity pe) Exrcrecate table ei(eno int pamangy key , erame vanckan(20>, Phone no bigint uniguo) fi IsuMtex®- for applying unique Key consteaints. . cece table eabiename Ccolocumn narn€ deitcury pes Conerratmt -CONSPsaTor Mame , COLUMN name daretye), Cweate: tabie e Cero Toe constscunt uq_e,_eng ENTE UL, enamMe Venchas(26?)) fey Ptac 3 toapely Woryue fey ComstsaFOtS after occing- Hoe. tcubie-— ee cuten table AB eC add unique Cemcme > Sapiax-2+ alton table table mane add cOnstearn constsasnname uniqur e€ colounnranme) ByOtAL-- tO drop antique key Cnstxaint'- Giten table tablename drop consr1aint Cconstsasnig. wnig ud + MOF NUIT Comsrecinr | Cocuncticlase € key Ou wn MM COE, accept dupticare ¢ UUs SIrOT tein Dluniqut F rohE GTI HOF accept ret valews @\wr BN Apply feos Than ONE UNTque FOr Mau constant of G& efngie tabie- gererecue table €zCeno IME Por NWI Unig, UL, L ename — vanchan(Ceo0)) . | ali 1 Jeormun [exe bicey JU Toot otuy, Gdupliccre - [ v a x x @ Nous values a x x vw x ae oF keys >I >I \ >I > & coneraints y vw Va -L name es as v = = = wy DEFaulr Constraints: tt ts ustd 40 Insert default value instead of Mu Value- “ | Syn Create Fable tabiencume (Co loumn narots dor. a deFaul+(Cdefauirvatuey) 2 checked Censtroint Firis urd 4 appy Some DISH ICLIONS OF the ColoumMDM Acue. SyMtove > ar lhe Hime Ch cxeaiting the tabie Svecte “tAbIe tebe NAME CCOIMAUMNE ‘ACHE TY PE» obec ts Ccondi ton), coiname doacursy pe) [CrECUue GO table rene CoH MUM, employes woits eno, ercume, scdemy POLY Crecked COMEPFOSO+ -fos EDO Colo -ComiHan iS €MO>100 yierete tanie emeCeno,int check (eno >100), Ojuniqtt+not nul copes sont wil hawe Constraint rong ; erame vancheur(20), as cruy money) BD me Comerarint rare checieCioret ye] CREATE CLADE Wb EAE PtH SOM, cotrh cole 4 penton fd, PeENsor MAME, AGE Cappy checiwecd qo constrain . Pox age Coleunmn beech OM COMdTHOD bige mast be greare thei 1S cige Murr be 9 go He€SS than 25 5 | r | glcvecde tabi€ pensonCpid Tnt,erame vast eave) | O oa FOE cCOMStwAINt Chk-POSON-F OC) ms age checkCagerisandageely Bunioxcifer applying checked conser nt apt o Preaing the t&bie + gO farer table tabename acd ches checks(coratnos}f O lex! cwecue a table With name employee cotth c loloumg eno, ename anc scary cpely Oo | checkecl cansraimr SBUORY szooo and sculery << 1200: check Ceaery > COO ff > 2 ganasyy

You might also like