Fayzullayev Akmaljon 614-20-guruh 24-25-26-laboratoriya ishi. Mavzu: sql da triggerlar yaratish. After delete mysql> delimiter // mysql> create trigger bolimlar



Download 200,71 Kb.
Sana19.02.2022
Hajmi200,71 Kb.
#458294
Bog'liq
Fayzullayev a 614 20 24 25 mbaza


Fayzullayev Akmaljon 614-20-guruh
24-25-26-laboratoriya ishi.
Mavzu: SQL da triggerlar yaratish.
AFTER DELETE.

mysql> DELIMITER //
mysql> create trigger bolimlar
-> after delete
-> on xodimlar_tr
-> for each row
-> set @del=@del+1;
-> //
Query OK, 0 rows affected (0.19 sec)







BEFORE DELETE.
mysql> delimiter //
mysql> create trigger manzili
-> before delete
-> on xodimlar_tr
-> for each row
-> begin
-> insert into manzili
-> values(old. fam, old.tugilgan_sanasi);
-> end//
Query OK, 0 rows affected (0.13 sec)



BEFORE UPDATE.
mysql> create trigger chesk_sanasi before update on tovar_savdosi
-> for each row
-> begin
-> if new.sanasi<0 then
-> set new. sanasi=0;
-> elseif new.sanasi>100 then
-> set new. sanasi=100;
-> end if;
-> end//
Query OK, 0 rows affected (0.17 sec)



AFTER UPDATE.
mysql> delimiter //
mysql> create trigger after_update
-> after update
-> on tovar_savdosi for each row
-> begin
-> insert into update_tovar_savdosi_2 values
-> (old.sotuvchi, old.tovar,old.sanasi,old.vaqti,old.miqdori,old.narxi,old.summasi);
-> end//
Query OK, 0 rows affected (0.14 sec)

mysql> update tovar_savdosi set sotuvchi='aliyev' where tovar ='oyinchoq'//
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0

BEFORE INSERT.
mysql> create trigger before_insert before insert
-> on tovar_savdosi_2 for each row
-> begin
-> if new. sotuvchi='aliyev'then
-> set new. sotuvchi='valiyev';
-> end if;
-> end//
Query OK, 0 rows affected (0.17 sec)

mysql> insert into tovar_savdosi_2 values
-> ('qurbonov','yongoq','8','10','10','6000000','550000'),
-> ('usmonov','xurmo','5','8','12','5000000','4500000')//
Query OK, 2 rows affected (0.19 sec)
Records: 2 Duplicates: 0 Warnings: 0


Xulosa: Biz ushbu laboratoriya ishida MySQL da trigger va funksiyalar yaratish bo’yicha ko’nikmalarga ega bo’ldik.
Download 200,71 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish