0% found this document useful (0 votes)
50 views17 pages

DBMS File Comp-1

Bdms file
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)
50 views17 pages

DBMS File Comp-1

Bdms file
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/ 17
{syntax : implementation:| ==] Output : mysql> show databases; _ os yes : | Database I + 4 | information_schema | | mysql | | performance_schema | I sys | | users a [Name : Cacate . [About : Ord de ouolt dabke Ina | derta bang, Syntax : courte tabi name (waluas type, =~)e| Implementation : couatt tab Sudo’ Cyl (Ar not null pochnas Ken, NOMA NaKcroalge) Poul Name vooehas(20), ago for)s Output: mysql> create table students( -> roll int not null primary key, -> name varchar(20), -> parentName varchar(20), -> age int); 0 rows affected (0.02 sec) IName : Tnx sh oe About : Jad Ae wi dala nde tables + Syntax : Touwi¥h ‘ele a blenaray va lus ( ‘esv)s Implementation : Toot inlo sludest valus( 20, Tahar, THamada’, 1) 2 Output : mysql> Insert into students values ( 20, Jake’, ‘Hamada’, 16); Query OK, 1 row affected (0.01 sec) mysql> select * from students; beeches oes | roll | name | parentName | age | peeeeeteeeetonn aon | 2|Cloe|grian | 19] | 20|Jake | Hamada | 16] + es Name : Select About : Dard ute select s6me arnoust co ta. goromn atable: Syntax : Implementation : Selet columnnames Output : Aclict * pm Nu dint Prateskidaurya/imysab select * from students; teveecetheneecennnenhanenen f | roll | nam name el parentNeme | age | 1 1 abla, yay : Name : About : [Dist Name: Sliminatis th ve puated iat Volucs em dha Been AT af colum Syntax : deck dian columnNane perm “blero Implementation : malet disine’ nome pom Duden « Output : mysql> select distinct name from students; | 3 rows in set (0.01 sec) Name: twhore About : Und 46 specify emdstion je Arusu'es « Syntax : seket colum rom table who condidion Implementation : | Aaclect 3 from Budsk whos woll = 208 | Output : mysql> select * from students where roll = 20 a hanna : [ roll | name | parentName | age | + jamada | 16 | + UU Name : Not About : Tig Uae OF not ppanater es nagar on 4 cond) Hrs - Syntax nbd & fiom Betws Fable, whov Implementation : pot colton? Output : mysql> select * from students where not name = E> ft + [roll | name | parentName | age | at ft | 20| Jake | Hamada | 16| | 31| Rahul | Raj | 20| + Name: Rn About : Utd a3 and opposer Ge cme eal 4wo condense : a | condition and canditions silot * Jxom BadeAta hse ~ \ - ft aames ' Alia’ and porunt Nam8 Rad! ka’; PrateekMaurya/mysq|> select * from students wher: ° @ name = Implementation : Output : Name : OR to BY OR Mate About : Und os indepondent- tmdition: ; Syntax : Condo tond'Hian _ConwTts) Implementation : caelect X duo — gladurty Wwhow rong 2 'Takal ot oll 312 e = Jake’ or roll = 31; : mysqi> select * from students where name = ‘Jake’ or roll = 31; Output : oe Ga ees pais | roll | name | parentName | age | ett tot | 20| Jake | Hamada | 16] | 31| Rahul | Raj | 20 qa tt Name : Oso By About : Vard AS taply twholk da Gort oidvud By a column 19 Spare pe Syntax : Sle ck céfissp om tobk Hdes py Col urn Implementation : Output : sel * ed sudan mo 4 ones J mysql> select * from Students order byage; bn ton acti | roll | name | parentName | | age | 1] Aisa | Andy | 13] | 20| Jake |Hamada | 16 | | 20] | 22] Name : About : eo) oe ae by aeafor chseending orders Syntax : vod by eodiven DESC? Implementation : \ ae lect % shorn Bludersty oder by Ofe Deses * from students order by age DESC; Output : PrateekMeurya/mysa select rom stu 5 roll | name | parentName | age | + es | 2| Aisa | Radhika | 22 | | 31] Rahul | Raj | 20) | 20 | Jake | Hamada | 16 | | 1| Aisa | Andy | 13] + Name : OPDatr 7 About : Changs thevalius in a tab 63 dha ghuen cam ch'Hony . Haeee Updo Fob Act cha whew Land ape Implementation : update Sudonts Ace P nt ny = grain who names 'cloe' mysql> update students set parentName =) Query Ok, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 sql select * from students; Brain’ where name = "logy oe Tie aon ke fron | a ta ble Syntax : Deleb pean tabu » hore LondHien $ Implementation : Dele from Srudeitg whou Holl=207 Output : mysql> delete from students where roll = 20; Query OK, 1 row affected (0.01 sec) mysql> select * from students; ee Name: Min Abi : a Rtusins Minin lement prom S2tene) Acleckd column. Syntax : Arleet min column) storm tobl Implementation : xelret min Cage’) juom Sudnt; Output : mysql> select min(age) from students; Name : Many About : Relwing row element stom the MEN column ? Syntax: select ro Ceolumn) pom Aabley Implementation : palo ror lage) jpem Bluderstay Output : PrateekMaurya/mysql> select max(age) from students; ae Litke | Ss © aba qornt fe Hod which is we 19 cond ans secu ch cya lus | syntax 3 DM leek osdore fob. whuu Oe Implementation : oli ko nia’ ay Loh xoduom Sudest wher nor UK Fores mysql> select * from ‘student where name like 'r% [Output : q fete tot | roll | name | parentName | age | pooceont | 10 | rawni| raju | NULL | 31] Rahul| Raj | 20] Name: AT: | About : Usd +0 dind values Ushich bel te 0 andy a values. rd ¥ Syntax : ~ == whe column jn (volw!2) Implementation : solel X piom Mudent rame inl! jake", Sahu! Je Output : mysqj> select * from student wher in (5 e nami 7 t "); meet peat eater fia a e in (‘jake’, 'rahul'); [roll | name | parentName | age | Jake | Hamada | 161 — : ertus n. ai ; ae Saul, wilh Canditien fo" sedi) Je a sarge g value a. Phe phate column betwen _ord_y Implementation : prhween °F 12 and 18 solect * por gludest whey age Output : PrateekMaurya/mysqi> select * from student where age between 13 and 18; + oe tot [roll | | parentName | age | tt —+—+ | 1] Aisa] Andy | 13] | 20 | Jake | Hamada | 16] feet penne Name : AS Calias) About : Replaces nanu & @ column dusd hs fateh ancl Aalect’s J Syntax : sabert Column a3 Auwcol nie Implementation : sob poourt/Vams a3 beuardian pean Sluderrt 3 Output : ‘mysql> select parentName as Guardian from student; | Guardian | ft [Andy | | Radhika | [raju | [Hamada | [Raj | ot j IN : : Tats + Ssallans fru va les wohich. hows jndoacetion 6) vale in two cables - synteny s sacl abled Inner join -eolumn\ table2, on Implementation : tebe. colamn = dabucz Baw aa lect * ye sludert inner yon admiasionat OO dudertbvoll = admisitst. s1allno; Output : mysql> select * from student inner join admissionlist on student.roll = admissionlist.rollno; + | roll | name | parentName | age | admission | rolino | fullname | + as eae penne | 689 | Aisa| Andy | 13] 32] 689|JohnDoe | | 831 | Jake | Hamada | 16| 78] 831 | Robert Wilson | to a Name: daft join: About : Just ~ Dike NNw join but includes s StomnaIning net Luss ofoat column, Syntax : Jaslect » from fabla). us join fobl2 on Implementation : tabty column = tobk S-columy aaleb ¥ Budrt be voln admissadbist on sludot® Ho UW = acl ston ist ove ltnos Output : See student left join admissionlist on student.roll = ee: 4 —+ [roll | name | parentName | age | admission | roling | fullname + 2| Alsa | Radhika | 22) NULL] NULL] NULL I [NULL | NULL] NULL] NULL = | | 20] NULL] NULL] NULL | 32| 689|JohnDoe | 78| 831 | Robert Wilson | + ; ral [Name : fei In. About : Tot Gea Wt join but he vd in cludes 9 samainin ae of Axto dab thy off E Syntax : ae ote den table xight dee : @ doblo on Ytoblex = sahl2-* } salt x pum gudett sign jo? AdmiasimUst on @udent.s 0 QdmiatonUst ~ Ho llno. Implementation : Output : PrateekMaurya/mysql> select * from student right join admissionlist on student.roll = admissionlist.rollno; | roll | name | parentName | age | admission | rollno | fullname — | proceeeheceeeeheeeennnnenaneee a —— + | 689 | Aisa| Andy | 13] 32| 689|JohnDoe | [NULL | NULL] NULL | NULL] 34] 367] Emily Davis | [NULL] NULL] NULL | NULL] 45] 227 | JaneSmith | [NULL] NULL] NULL =| NULL] 76] 127 | Michael Johnson | | 831 |Jake | Hamada | 16] 78| 831] Robert Wilson | te a ee Name: | { Count About : Counts no. of Na tuts 1” giro column at Syntax : Sect courrCeolumn) duom tables Implementation: | go tyct count C¥) dhcorm SludeAt- group a namsg mysql> select count(*) from student group by name; + i DRoP. rors WF ud te lel 4obu/covobae Syntax: Dowp tobl/dalabax Larne ? Implementation : Cxop table wudnt; Output : mysql> drop table students; Query OK, 0 rows affected (0.02 sec) : mysql> select * from students; ERROR 1146 (42502): Table ‘users.students' doesn't exist Name : Teuncals About : . MH jg wad dé chikte all valu jprom the Ginen dabk. Syntax : founcote abl, toblename + Implementation : +xuneate table wren: Output : mysql> truncate table users; Query OK, 0 rows affected (0.03 sec) mysql> select * from users; Empty set (0.00 sec) aBeuet ee a add /ehange column? +0 dobu Syntax : pNex table Aome ducky) acd enor Fepus Implementation : alten table. Budint add clans sya choy G): PrateekiViaurya/mysqi> alter table student add class varchar(1); Output : : Query OK, 0 rows affected (0.02 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> select * from student; ae es | roll | name | parentName | age | class | opneeancneebeccnenbeeneeh isa | Radhika | 22| NULL | | 10 | rawni | raju | NULL | NULL | | 31] Rahul | Raj =| 20] NULL | — + Name : Sum. Sea 7 ett Finds Surs alt element of gina Column . Syntax : dell cum ( colurnn) prod iss Implementation : deleb coum lage) jprom, Sucka s Output : mysql> select sum(age) from student; fhe + ‘ : Aljex : aes Uua +o add /ehonge column +6 dobU Syntax : Na, Abu Moms’ Guides add cnarne fepss Implementation : alten, table Bludint add claw vax Choy ti): PrateekMaurya/mysql> alter table student add class varchar(1); Output : Query OK, 0 rows affected (0.02 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> select * from student; + | roll | name | parentName | age | class | - | 2| Aisa | Radhika | “22 | NULL | | 10 | rawni| raju | NULL | NULL | | 31 | Rahul | Raj | 20| NULL | Name: x um, About : y Finds Sura all elumant 4 grunl Column . Syntax : Soloed dum (column) pron l : Output : Implementation : ath un pl foam dhaknt mysql> see sum(age) from Student; : DN Gr Canasage) ea Fin owoigd ) ied aan, Syntax : palict avg Coolum) table Implementation : erbett arg Lagi) pom dudent § Output : mysql> select avg(age) from student; | ave(age) | bot | 17.7500 | Name: Count About : Count’ no. of SOW; Jn give colunn, Cray ned © 46 solinfd & Condition), Syntax : Atlet court (ce lumn)ghiom table» Implementation : aolket count (x) spor studs rit: Output : _| ba + | count(*) | to + | mysql> select count(*) from students; Full Join Spout At dinds csoaa. powoduct of each. About : i Ad avo entole pom fogt table | dab ——__— [ Syntax: getrct column porn table! oT ‘in. tabl2s Tt n implementation: | 92eL X om Hudink fut Jo ‘ ad miasion Liat ° Output : Pratekaurya/mysa select * fom student ful join admisionist | [roll | name | parentName | age | admission | rollno | fullname 1 + — | 831 | Jake | Hamada | 16 | 32 | 689 | John Doe 1 689 | Aisa | Andy 1 13] 32 | 689 | John Doe | | 31 | Rahul | Raj | 20] 32| 689 | John Doe 1 10 | rawni|raju | NULL] 32] 689|JohnDoe | 2| Aisa | Radhika | 22| 32] 689|JohnDoe | 831| Jake |Hamada | 16| 34] 367] Emily Davis | 689] Aisa | Andy | 13] 34 367] Emily Davis | 31] Rahul | Raj. | 20) 34] 367 | Emily Davis | 10 rawni | raju | NULL 34] 367 | Emily Davis | 2 |Aisa | Radhika | 22| 34] 367 | Emily Davis | 831 | Jake |Hamada | 16| 45] 227 | Jane Smith I | 689 | Aisa |Andy | 13] 245!" 227 | Jane Smith | 31 [Rahul | Raj | 20. BAST 297 | Jane Smith | 10 | rawni|raju | NULL | 45 | 227 | Jane Smith I 2 Aisa | Radhika | 22| 45 | 227 | Jane Smith | 831 | Jake |Hamada_ | 16] 76 | 127 | Michael Johnson | 689 | Aisa |Andy | 13] 76] 127 | Michael Johnson | 31| Rahul | Raj | 201-76 127 | Michael Johnson | 10 | rawni | raju | NULL 1 76| 127 i | ani slag | Michael Johnson | 122) 761 127) mi 831 [Jake |Hamada | 16] 7g | at eee hnson | 689 | Alsa |Andy | 13] 78 831 | Robert Wilson. } 31 [Rahul | Raj | 204 781 831 | Robert wit mi 10 rawnl |raju | NULL] 78] a 83. i Aisa | Radhika | 22 | 11 Robert Wilson. | ees *

You might also like