Tranzaksiyalarni boshqarishda so‘rovlar yaratish va qayta ishlash
SQL muhitida tranzaksiyalani boshqarish
Download 29.19 Kb.
|
1 2
Bog'liqSql
- Bu sahifa navigatsiya:
- Nazorat savollari
SQL muhitida tranzaksiyalani boshqarish.SQL tilida tranzaksiyalami maxsus operatorlatyordamida boshqarish imkoniyati mavjud. Shulardan biri tranzaksiya parametrlarini o‟matish operatori bo'lib, uniyozilish formati quyidgicha: SET TRANSACTION transaction mode> [ { transaction mode> ::= | | «diagnostics size> «isolation level> ::= ISOLATION LEVEL «level of isolation> READ UNCOMMITTED | READ COMMITTED i REPEATABLE READ | SERIALIZAB1 1 transaction access mode> READ ONLY | READ WRITE diagnostics size> ::= DIAGNOSTICS SIZE Agar himoya darajalari ko'rsatilmasa, himoya darajasi SERIALIZABLE deb tushumniladi. Agar ruxsat tartibi READWRITE kalit so'zi bilan belgilansa, unda himoyalanish darajasi READUNCOMMITTED bo'lmasligi kerak. Agar ruzsat tartibi va himoyalanish darajasi READUNCOMMITTED deb ko'rsatilsa, unda beriladigan ruxsat tartibi READONLY deb tushuniladi, aks hollarda ruxsat tartibi READWRITE bo'ladi. Ko'pchilik hollarda tranzaksiyalaming bajarilish jarayonida MB jadvallari stmkturasi buzilishining oldini olish uchun tranzaksiyalarga faqat o'qish tartibini o'rnatish mumkin. Buning uchun quyidagi operator ishlatiladi: SET TRANSACTION READ ONLY; Bu operator tranzaksiya jarayoni boshlanishidan oldin ko'rsatiladi. Masalan, EXEC SQL SET TRANSACTION READ ONLY; Buyurtmalarni qabul qilgan sotuvchini aniqlamoqchmiz. Bu ikki so‟rovni bir- biridan farq qilishi uchun matn kiritish yo'li bilan tashkillashtirisimiz mumkin: SELECT a.snum, sname, onum, ‟Highest on‟, odate FROM Salespeople a. Orders b WHERE a.snum = b.snum AND b.amt = (SELECT MAX (amt) FROM Orders с WHERE c.odate = b,odate) UNION SELECT a.snum, sname, onum, ‟Lowest on‟, odate FROM Salespeople a, Orders b WHERE a.snum b.snum AND b.amt = (SEi FCT MIN (amt)FROM Orders с WHERE c.odate ; b.odate); 10 Peel 30 High o 10/05/
10 Axel 30 High o 10/04/ Shu paytgacha UNION kalit so‟zi yordamida birlashtirilgan so'rov natijalari qanday tartibda matnga chiqarilishi to'g‟risida gapirmadik. Birlashtirilgan natijalarni ORDER BY kalit so'zi yordamida tartiblashtirish mumkin. Yoqoridagi misolni tartub raqamlariga nisbatan tartiblashni ko'rib o'tamiz. SELECT a.snum, sname, onum, ‟Highest on‟, odate FROM Salespeople a. Orders b WHERE a.snum = b.snum AND b.amt = (SELECT MAX (amt) FROM Orders с WHERE c.odate = b.odate) UNION SELECT a.snum, sname, onum. ‟Lowest on‟, odate F ROM Salespeople a. Orders b WHERE a.snum = b.snu AND b.amt = (SELECT MIN (amt) FROM Orders с WHERE c.odate = b.odate) ORDER BY 3; Natija quyidagicha:
Nazorat savollariSQL muhitida tranzaksiyaning vazifasi nimadan iborat? TCL uchun muhim jarayon qaysi? Commit nima vazifani bajaradi? Misol keltiring. Tranzaksiyalarni boshqarishni tushuntiring? Rollback uchun misol keltiring? Download 29.19 Kb. Do'stlaringiz bilan baham: |
1 2
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling