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

My SQL

MY SQL cover page

Uploaded by

camuditarora
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)
12 views

My SQL

MY SQL cover page

Uploaded by

camuditarora
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/ 7
Section-C MySQL- SQL Command @ Scanned with OKEN Scanner Section-C MySQL- SQL Commands @ Scanned with OKEN Scanner PLOYEE “"PATABASE ORGANIZATION AND QUERIES APPLIED ON TABLES EMPL mysql> cr ate database organization; Query OK + 1 row affected (0.00 sec) BYSQ1> Use ony ganization; D, atabase changed SYSA1> create table employee . TE fEne Anteger NOT MULL. PRIMARY key, 23 Ename varchar(3o), TP Retery decimal (9,35, 23 Ogaress varchan(4o)” Query UePEND-tntenen how Nut) 5 Tews affected (0.09 sec) ' key | Default | Extra | awecaay ~7-} varchar(sey | secimai (3,2) | varchantagy \ No 1 Yes | Yes I 1 jee ins, ert into em Ployee vy, *,10)5 TY ORs A row merectear ee ge ®YSAl> Insert ant, 3 Par eec eee te yatues (2. Suprtya* 3000.9 “Vasant Vihar“,20); Sry OK, a row affected es. vm sec) i ooanarae): »55000.09, ‘Nehru Enclave*,30); SUES Baden’ .45000.00,-Ring Roma: aos 2 row affected (®.13 sec) : aeeane a Gee Bas insert ante employes yalues(S, “rythm Beery OKT how are ey eS | +65009.00, Moder Town" .20); 6 sec) ~ a Model Town iia ar ! | Sovind Kung] 28 | | 2 1 Supriya | 3500000 | Vasant Vihar | 22 | 1 3 1 Raq | 550@0-00 | Nehru Enclave 1 30 | | 41 Rajan | aseeo-eo | Ring Road | ae | | 1 1 1 \ s 1 $5000.00 | Nehru Enclave | * in set (0.03 sec) @ Scanned with OKEN Scanner “ m employee mysql> Select Eno,Ename fro: ploy Add: TN('Vasant. Vihar’, "Ring Road’) <> where ress. 2 rows in set (0.00 sec) mysql> select distinct deptno from employee; ™YSG1> select de: >> order by PENC.LeNO,ename from employee deptno,eno; S rews an set (o.oo ee Sse) from employee | Supriya Raj rows in set (0.00 sec) mysql> select ename,Salary from employee => where deptno IS NOT NULL; 35020.00 55000.00 45020.00 65020.00 | 5 rows in set (8.00 sec) mysql> select substring(ename,2,4) +: --+ | substring(ename,2,4) | from employee where length(ename)>4; @ Scanned with OKEN Scanner mysql> select «i bstring(ename, -5,4) * sub from employee nace ployee where length(ename) >45 1 Suni pray Raja Ryen 4 rows in nae (0.00 S65 SARNCConame.4) from employes whe, LenKthConame) >a 7 re Ployee \ Jengtn¢ Cen 5 BYPS2> serece tween frome mpLoyee whe: Ployee where Length Ceneme) >a; 1ounaa 2 - 5 + news an set (0.60 sec) ma cana aay Pat i 3 Soe Govind Kunj 7 [2 T Supriya Vasant Vinar | 30 | | meade Nehru Enclave I 30 | | 2 1 Rodan Ring Roaa "| 38 ! 2 Moder town f 38 | 5 rows in set (8.00 sec) gysai> select sum(salary),Aavg(salary) from employee Group by deptnos 3 rows in set (®.05 sec) MIN(salary),MAX(salary) From employee Group by deptno; mysql> select ] min¢satary) | MAx(salary) | 1 49500.00 | 4950.00 | | 38a00:00 | 6800000 | 1 58000.e0 | $5000.00 | 3 mysql> select MIN(salary),MAX(salary) from employee by deptno Having Deptno>20: @ Scanned with OKEN Scanner + | MIN(salary) | MAX(salary) | 1 55000.00 | = 55000.00 | -+ 1 row in set (0.08 sec) mysql> select MIN(salary),MAX(salary) from employee ~> Group by deptno Having count(*)>1; so-t-- + J min(saiary) 1 Max(salary) | - + | 4950.00 | -49500.00 | 35000.00 | 5000.00 | 2 rows in set (0.00 sec) mysql> se: _ Sees pmtsalary) ,Avatsalary) from employee 'p by deptno Having sum(salary)>99000 AND Avg(salary)>40000; | sum(saiary) | avg(salary) 1 7 — row in set (8.00 sec) mysql> Alter table e i mployee drop Prima Key; Query OK, 5 rows affected (0.28 sec) ‘ecords: 5 Duplicates: @ Warnings: @ mysql> desc employee; I Key | Defauit| Extra | Eno [ antqaay I no I }nu | 1 | Ename =| varchar(30) | Yes | Pnuce | | Salary | decimai(s,2) | ves | [nue | I I Address | varchar(40) | YES = | [nue 1 1 I] Deptno | int(21) I no I | 1 5 rows in set (0.8 sec) mysql> Alter table~émployee Add Primary Key(Eno) 5 Query OK, 5 pws affected (0.23 sec) Records: 5/“buplicates: @ Warnings: © mysql> desc employee; + | Field | Type [muir 1 Key | Defauael Extra | | Eno | ant(aa) 1 No }pRr | nu | 1 | Ename | varchar(30) | Yes | [nut | 1 [ salary | decimai(9,2) | Yes | | 1 | Address | varchar(40) | Yes | [nue | \ | Deptno | int(11) 1 No | [nue | ooo + --4- $ rows in set (@.00 sec) sql> Alter table employee Add(Experience integer) Query OK, 5 rows affected (0.23 sec) Steords: 5 Duplicates: @ Warnings: © i> Alter table employee Modify Ename varchar(30) Not Null; Dery ‘OK, 5 rows affected (@.22 sec) query oes Duplicates: @ Warnings: © @ Scanned with OKEN Scanner mysql> desc employee; tense pac \ Type | Fiela meee ie \ 1 amecaay \ J prt joni | | varchar(so) | \ 1 nui | | deeimar(a,) | | | | varchar(aoy | | 1 nu | | 1 antqiiy 1 | Ionut | | Vo ant(aay \ | Tue | * * + Ployee change Expert ence Expyears integer; Records: @ pos affected (0.03 Sec) : + @ Duplicates: @ Warnings: 0 Rysql> ery ee employee set E, wa 2n4-n ee | Eno | Ena 45002.08 | Ring Road 6500.08 | Model Town jl> drop table employee; OK, @ rows affected (8.06 sec) sql> desc employee; 1146 (42502): Table “organization. employee’ eacher's Signature: doesn't exist an x @ Scanned with OKEN Scanner

You might also like