INSERT INTO oquvchilar VALUES(37,'Ilyosxonova','Munazila','10-sinf','A'); INSERT INTO oquvchilar VALUES(38,'Erkinov','Aziz','9-sinf','A');
INSERT INTO oquvchilar VALUES(39,'Yo`ldoshev','Ibrohim','10-sin','B'); INSERT INTO oquvchilar VALUES(40,'G`aniyeva','Rayhona','10-sinf','A'); INSERT INTO oquvchilar VALUES(41,'Rizayeva','Munisa','9-sinf','A'); INSERT INTO oquvchilar VALUES(42,'Yo`ldosheva','Lola','9-sinf','B'); INSERT INTO oquvchilar VALUES(43,'Xoliqova','Muqaddas','11-sinf','A'); INSERT INTO oquvchilar VALUES(44,'Yarasheva','Rano','11-sinf','A'); INSERT INTO oquvchilar VALUES(45,'Yo`ldoshev','Bobur','9-sinf','B'); INSERT INTO oquvchilar VALUES(46,'Rixsiyev','Zohid','9-sinf','A'); INSERT INTO oquvchilar VALUES(47,'Karimboyeva','Nigora','11-sinf','B'); INSERT INTO oquvchilar VALUES(48,'Qodirov','Ulug`bek','11-sinf','A');
INSERT INTO oquvchilar VALUES(49,'Matyusupov','Yo`ldoshbek','9-sinf','B'); INSERT INTO oquvchilar VALUES(50,'Sherimmetov','Davron','10-sinf','B');
insert into fanlar values
(1,5,4,5,3,5,5),(2,3,4,4,3,5,4),(3,5,5,5,5,5,5),(4,3,4,4,3,3,4),(5,5,4,4,4,4,
5),(6,5,4,4,5,4,5);
INSERT INTO fanlar VALUES(7,4,4,5,3,3,4); INSERT INTO fanlar VALUES(8,4,4,5,3,3,4); INSERT INTO fanlar VALUES(9,4,5,5,5,5,5); INSERT INTO fanlar VALUES(10,4,3,3,3,4,4); INSERT INTO fanlar VALUES(11,4,3,3,5,5,4); INSERT INTO fanlar VALUES(12,4,4,5,5,4,4); INSERT INTO fanlar VALUES(13,3,3,3,3,3,3); INSERT INTO fanlar VALUES(14,4,3,3,5,4,3); INSERT INTO fanlar VALUES(15,4,4,5,5,4,5); INSERT INTO fanlar VALUES(16,3,3,5,5,4,4); INSERT INTO fanlar VALUES(18,4,3,4,5,4,5); INSERT INTO fanlar VALUES(19,4,4,5,4,4,4); INSERT INTO fanlar VALUES(20,4,3,5,5,4,4); INSERT INTO fanlar VALUES(21,3,3,3,3,3,3); INSERT INTO fanlar VALUES(22,5,3,5,5,4,3); INSERT INTO fanlar VALUES(23,3,3,5,5,4,4); INSERT INTO fanlar VALUES(24,4,5,5,5,5,4); INSERT INTO fanlar VALUES(25,4,3,4,5,4,4); INSERT INTO fanlar VALUES(26,4,3,5,4,4,5); INSERT INTO fanlar VALUES(27,4,5,4,5,4,4); INSERT INTO fanlar VALUES(28,4,3,5,5,4,4); INSERT INTO fanlar VALUES(29,5,5,5,5,5,5); INSERT INTO fanlar VALUES(30,4,3,5,5,4,4); INSERT INTO fanlar VALUES(31,4,3,5,5,4,4); INSERT INTO fanlar VALUES(32,4,3,5,5,4,4); INSERT INTO fanlar VALUES(33,4,3,3,3,3,4); INSERT INTO fanlar VALUES(34,4,3,4,3,4,5); INSERT INTO fanlar VALUES(35,5,4,5,5,4,5); INSERT INTO fanlar VALUES(36,4,4,4,4,4,4); INSERT INTO fanlar VALUES(37,5,4,5,5,4,4); INSERT INTO fanlar VALUES(38,4,5,5,3,4,3); INSERT INTO fanlar VALUES(39,3,3,3,4,4,3); INSERT INTO fanlar VALUES(40,4,3,5,5,4,4); INSERT INTO fanlar VALUES(41,5,3,3,4,3,4); INSERT INTO fanlar VALUES(42,4,5,5,5,4,5); INSERT INTO fanlar VALUES(43,3,4,4,5,4,4); INSERT INTO fanlar VALUES(44,4,5,5,5,4,5); INSERT INTO fanlar VALUES(45,4,5,5,4,4,4); INSERT INTO fanlar VALUES(46,5,5,5,5,4,4); INSERT INTO fanlar VALUES(47,5,4,4,5,4,4); INSERT INTO fanlar VALUES(48,5,4,5,4,4,5); INSERT INTO fanlar VALUES(49,3,4,5,5,4,3); INSERT INTO fanlar VALUES(50,3,3,4,5,4,3);
select *from xodimlar; select *from Oquvchilar; select *from fanlar;
UPDATE xodimlar SET oyligi=3000000 WHERE xodim_ID=1; UPDATE xodimlar SET oyligi=3500000 WHERE xodim_ID=2; UPDATE xodimlar SET oyligi=5000000 WHERE xodim_ID=3; UPDATE xodimlar SET oyligi=4600000 WHERE xodim_ID=4; UPDATE xodimlar SET oyligi=7000000 WHERE xodim_ID=5; UPDATE xodimlar SET oyligi=6600000 WHERE xodim_ID=6; UPDATE xodimlar SET oyligi=10000000 WHERE xodim_ID=7; UPDATE xodimlar SET oyligi=4500000 WHERE xodim_ID=8; UPDATE xodimlar SET oyligi=3900000 WHERE xodim_ID=9; UPDATE xodimlar SET oyligi=5800000 WHERE xodim_ID=10; UPDATE xodimlar SET oyligi=6000000 WHERE xodim_ID=11; UPDATE xodimlar SET oyligi=5000000 WHERE xodim_ID=12; UPDATE xodimlar SET oyligi=5000000 WHERE xodim_ID=13; UPDATE xodimlar SET oyligi=8200000 WHERE xodim_ID=14; UPDATE xodimlar SET oyligi=4000000 WHERE xodim_ID=15; UPDATE xodimlar SET oyligi=7000000 WHERE xodim_ID=16; UPDATE xodimlar SET oyligi=6000000 WHERE xodim_ID=17; UPDATE xodimlar SET oyligi=6000000 WHERE xodim_ID=18; UPDATE xodimlar SET oyligi=7700000 WHERE xodim_ID=19; UPDATE xodimlar SET oyligi=5400000 WHERE xodim_ID=20;
Oquvchilar jadvalidagi Familiya ustuni bilan Xodimlar jadvalidagi Ism ustunini bog`lash:
SELECT Familiya FROM oquvchilar
UNION
SELECT Ism FROM xodimlar
ORDER BY Familiya;
Oquvchilar jadvalidagi Ism vas inf ustuni bilan Xodimlar jadvalidagi fani va oyligi ustunini bog`lash:
SELECT Ism, sinf FROM oquvchilar
UNION ALL
SELECT fani, oyligi FROM xodimlar;
Mavzu: Standart funksiyalardan foydalanib so‘rovlar yaratish
Ishdan maqsad: Berilgan predmet soha ma`lumotlar bazasidan foydalanib standart funksiyalardan foydalanib so‘rovlar yaratishni o`rganish.
Masalani qo`yilishi: Predmet soha ma`lumotlar bazasi shakllantirilgandan so`ng ob`yektlardagi ma`lumotlar ustida o`zgartirishlar qilish uchun standart funksiyalardan foydalanib ishlash mumkin.
SELECT LOWER(Familiya) FROM xodimlar;-satrni kichik harfda chiqaradi
SELECT UPPER(Ism) FROM oquvchilar;-satrni katta harfda chiqaradi
SELECT RPAD(fizika,3,’.0’) FROM fanlar;-o`ng qatorni malum bir uzunlikdagi simvol bilan to`ldiradi
SELECT LENGTH(mutaxasislik) FROM xodimlar;-qator uzunligini aniqlaydi
SELECT LENGTH(Ism) FROM oquvchilar;-qator uzunligini aniqlaydi
SELECT LTRIM(mutaxasislik) FROM xodimlar;-qator boshidan (probel)ni olib tashlaydi
SELECT LEFT(sinf,2) FROM oquvchilar;-satr boshidan malum bir belgigacha ko`rsatadi
SELECT REVERSE(Ism) FROM xodimlar;-satrni o`zgartiradi yani ongdan chapga joylashtiradi
Mavzu: Agrеgat funksiyalardan foydalanish
Ishdan maqsad: Berilgan predmet soha ma`lumotlar bazasida agregat funksiyalaridan foydalanishni o`rganish.
Masalani qo`yilishi: Predmet soha ma`lumotlar bazasi shakllantirilgandan so`ng ob`yektlardagi ma`lumotlarni guruhli agregat funktsiyalar orqali ishlash.
SELECT fan_id,ROUND(fizika /matematika,3) FROM fanlar;- butun sonni yaxlitlaydi.
SELECT fizika,rus_tili, POWER(fizika,rus_tili)FROM
fanlar;
-fanlar jadvalidagi fizika ustunidagi qiymatlarni rus tili ustunidagi qiymatlar darajasini aniqlaydi.
SELECT kimyo, LOG(kimyo)FROM fanlar;
- fanlar jadvalidagi kimyo ustunidagi sonlarning natural lagorifmini hisoblaydi.
SELECT MID(Familiya,1,1),Familiya,MID(Ism,2,1),Ism FROM xodimlar;-
Xodimlar jadvalidagi Familiya ustunining birinchi harfini Ism ustuninging ikkinchi harfini chiqarish.
Ishdan maqsad: Berilgan predmet soha ma`lumotlar bazasidan foydalanib, bir nеchta jadvallar birlashtirish, JOINlar bilan ishlash.
Masalani qo`yilishi: Predmet soha ma`lumotlar bazasi shakllantirilgandan so`ng ob`yektlardagi ma`lumotlarni birlashtirish maqsadida INNER JOIN, LEFT JOIN, RIGHT JOIN, CROSS JOIN, FULL OUTER
JOIN va ON standart so`zlaridan foydalanish. Barcha ob`yektlardagi ma`lumotlarni yuqoridagi standart so`zlar orqali birlashtiradigan so`rovlar tashkil etish.
SELECT Familiya,Ism,sinf, fizika,ingliz_tili,kimyo,rus_tili,matematika FROM oquvchilar AS o
INNER JOIN fanlar AS f ON
o.oquvchi_id=f.fan_id;
-Inner join orqali oquvchilar va fanlar jadvalini bir biri bilan bog`landi.
SELECT COUNT(o.oquvchi_id),fizika FROM
oquvchilar AS o
INNER JOIN fanlar AS g ON o.oquvchi_id =g.fan_id GROUP BY g.fizika;
-bu yerda fizika fanidan nechta 3,4 va 5 olgan talabalar sonini aniqladik.
SELECT oquvchi_id,Familiya,Ism,matematika FROM
oquvchilar AS o
RIGHT JOIN fanlar AS f
ON o.oquvchi_id=f.fan_id WHERE matematika=3;
-matematika fanidan 3 baho olgan talabalarni ekranga chiqarib beradi
Xulosa
Xulosa o’rnida shini aytishim mumkinki, mustaqil ishni bajarish jarayonida Standart funksiyalardan foydalanishni UNION,INTERSECT va MINUS standart so`zidan foydalanishni Agregat funksiyalardan foydalanishni va Bir necha
jadvallarni birlashtirish, “Join”lar bilan ishlashni o`rgandik.
Foydalanilgan adabiyotlar
www.intiut.ru;
www.oracle.com
Usmonov J.T., Xujaqulov T.A. Ma’lumotlar bazasini boshqarish tizimi// o`quv qo`llanma. - Т. : Aloqachi, 2018. – 96 b.
Usmonov J. T., Xo'jaqulov T. A. Ma'lumotlar bazasini boshqarish tizimi fanidan laboratoriya ishlarini bajarish bo'yicha uslubiy ko'rsatma - Т. : TATU, 2016. – 55 b.
В.П. Базы данных. Книга 2 распределенные и удаленные базы данных: учебник.// Москва ИД «ФОРУМ» - ИНФРА-М. – 2018. – С 261.
Голицына О.Л. Базы данных: учеб. Пособие // – 4-е изд., перераб. И доп. – М.: ФОРУМ: ИНФРА-М, 2018. – 400 с.
Do'stlaringiz bilan baham: |