1
THE JOINSजॉइन
A JOIN combines rows from two tables on a matching column.
- INNER JOIN: only the rows with matching values in BOTH tables. JOIN alone means INNER JOIN
- LEFT OUTER JOIN: every row of the LEFT table, with NULL where the right has no match
- RIGHT OUTER JOIN: every row of the RIGHT table, with NULL where the left has no match
- FULL OUTER JOIN: every row of both tables
- SELF JOIN: a table joined to itself
- CROSS JOIN: every row paired with every row, the CARTESIAN PRODUCT
- इनर जॉइन: केवल वे पंक्तियाँ जिनके मान दोनों तालिकाओं में मेल खाते हैं। अकेले जॉइन का अर्थ इनर जॉइन है
- लेफ्ट आउटर जॉइन: बाईं तालिका की हर पंक्ति, जहाँ दाईं में मेल न हो वहाँ NULL
- राइट आउटर जॉइन: दाईं तालिका की हर पंक्ति, जहाँ बाईं में मेल न हो वहाँ NULL
- फुल आउटर जॉइन: दोनों तालिकाओं की हर पंक्ति
- सेल्फ जॉइन: तालिका का स्वयं से जॉइन
- क्रॉस जॉइन: हर पंक्ति हर पंक्ति के साथ, अर्थात् कार्टेशियन गुणनफल
2
NESTED QUERIESनेस्टेड क्वेरी
In a NESTED QUERY, the result of one query, the SUB-QUERY, is used by another query.
- EXISTS is true if the sub-query returns at least one row, and false if it returns none
- ANY and SOME are true if the value matches at least one value the sub-query returns
- ALL is true only if the value satisfies the condition for every value returned
- A CORRELATED sub-query refers to the outer query, so it runs once for each outer row
- EXISTS सत्य है यदि सब-क्वेरी कम से कम एक पंक्ति लौटाए, और असत्य यदि कोई न लौटाए
- ANY और SOME सत्य हैं यदि मान सब-क्वेरी के लौटाए किसी एक मान से भी मेल खाए
- ALL तभी सत्य है जब मान लौटाए गए हर मान के लिए शर्त पूरी करे
- कोरिलेटेड सब-क्वेरी बाहरी क्वेरी का संदर्भ लेती है, इसलिए हर बाहरी पंक्ति के लिए एक बार चलती है
3
GROUP BY AND HAVINGGROUP BY और HAVING
- GROUP BY collects rows with the same value into groups, so a group function works on each group
- HAVING filters the GROUPS, just as WHERE filters the rows
- WHERE runs before grouping; HAVING runs after it
- SELECT deptno, AVG(sal) FROM emp GROUP BY deptno HAVING COUNT(*) > 5 gives the average pay of departments with more than five people
- ROWNUM in Oracle limits the rows returned, as in WHERE ROWNUM <= 5
- GROUP BY समान मान वाली पंक्तियों को समूहों में रखता है, ताकि ग्रुप फंक्शन हर समूह पर चले
- HAVING समूहों को छानता है, जैसे WHERE पंक्तियों को छानता है
- WHERE समूह बनाने से पहले चलता है; HAVING उसके बाद
- SELECT deptno, AVG(sal) FROM emp GROUP BY deptno HAVING COUNT(*) > 5 पाँच से अधिक लोगों वाले विभागों का औसत वेतन देता है
- ओरेकल में ROWNUM लौटाई गई पंक्तियाँ सीमित करता है, जैसे WHERE ROWNUM <= 5
4
INDEXES AND QUERY PARSINGइंडेक्स और क्वेरी पार्सिंग
- An INDEX maps a column's values to their ROWIDs. A rowid gives the file, the block and the row
- An index is a tree: smaller values go left of their parent. This is the B-TREE index
- Index the columns your queries use often. Do NOT index columns with few unique values, or small tables
- When a query is PARSED, the syntax is checked, and the objects are checked to exist
- The parser then checks your access rights, and finds the OPTIMAL PATH, the execution plan
- इंडेक्स कॉलम के मानों को उनके रोआईडी से जोड़ता है। रोआईडी फाइल, ब्लॉक और पंक्ति बताता है
- इंडेक्स एक वृक्ष है: छोटे मान अपने पैरेंट के बाएँ जाते हैं। यह बी-ट्री इंडेक्स है
- उन कॉलमों पर इंडेक्स बनाएँ जिन्हें आपकी क्वेरी अक्सर उपयोग करती हैं। कम अद्वितीय मानों वाले कॉलमों, या छोटी तालिकाओं पर इंडेक्स न बनाएँ
- क्वेरी पार्स होने पर सिंटैक्स जाँचा जाता है, और ऑब्जेक्टों का अस्तित्व जाँचा जाता है
- फिर पार्सर आपके पहुँच अधिकार जाँचता है, और सर्वोत्तम मार्ग, अर्थात् निष्पादन योजना, खोजता है