Views in SQL in Hindi
Table of Contents
- Views in SQL in Hindi
- Types of Views in Hindi
- Advantages of Views in Hindi
- Disadvantages of Views in Hindi
- Examples of Views in SQL in Hindi
- FAQ
Views in SQL in Hindi – SQL View क्या है? (Types, Advantages, Examples)
SQL में View एक virtual table (आभासी तालिका) होती है, जो एक या एक से अधिक tables के data को combine करके बनाई जाती है। View खुद data store नहीं करती, बल्कि यह underlying tables से data को fetch करके दिखाती है।
सरल शब्दों में, View एक saved query होती है जिसे हम बार-बार उपयोग कर सकते हैं। इससे complex queries को simplify करना आसान हो जाता है।
जब भी हम view को access करते हैं, database उस view की query को execute करता है और result दिखाता है।
Views का उपयोग security, data abstraction और query simplification के लिए किया जाता है।
DBMS और SQL exam में views एक बहुत important topic है क्योंकि यह real-world database design में बहुत उपयोगी होता है।
---View की मुख्य विशेषताएँ
- View एक virtual table होती है
- यह data store नहीं करती
- यह complex queries को सरल बनाती है
- Security के लिए उपयोगी होती है
- Multiple tables से data दिखा सकती है
Types of Views in Hindi (Views के प्रकार)
SQL में Views को उनके behavior और structure के आधार पर कई प्रकारों में बांटा जाता है:
---1. Simple View
Simple view एक ही table से बनाया जाता है और इसमें कोई complex operation जैसे join या group by नहीं होता।
उदाहरण:
CREATE VIEW StudentView AS SELECT Name, Age FROM Student;
यह view केवल Student table से data दिखाएगा।
---2. Complex View
Complex view multiple tables, joins, group by, aggregate functions आदि का उपयोग करके बनाया जाता है।
CREATE VIEW StudentMarksView AS SELECT s.Name, m.Marks FROM Student s JOIN Marks m ON s.ID = m.ID;---
3. Materialized View
Materialized view data को physically store करती है, जिससे performance improve होती है।
यह सामान्य views से अलग होती है क्योंकि इसमें data stored रहता है।
---4. Inline View
Inline view एक temporary view होती है जो query के अंदर ही define की जाती है।
SELECT * FROM (SELECT Name, Marks FROM Student) AS TempView;---
5. Read-Only View
इस प्रकार के view में data को update नहीं किया जा सकता।
---6. Updatable View
इस view के माध्यम से data को insert, update और delete किया जा सकता है (कुछ conditions के साथ)।
---Advantages of Views in Hindi (Views के फायदे)
- Security:
User को limited data दिखाने के लिए views का उपयोग किया जाता है।
- Data Abstraction:
Complex queries को hide करके simple interface प्रदान करता है।
- Reusability:
एक ही query को बार-बार लिखने की जरूरत नहीं होती।
- Simplifies Queries:
Complex joins और calculations को आसान बनाता है।
- Consistency:
Same query result बार-बार consistent तरीके से मिलता है।
- Performance (Materialized View):
Materialized view performance improve करती है।
Disadvantages of Views in Hindi (Views के नुकसान)
- Performance Issue:
Complex views slow हो सकते हैं।
- Limited Update:
हर view updatable नहीं होता।
- Dependency:
अगर underlying table change हो जाए तो view भी affect होता है।
- Storage (Materialized View):
Materialized view extra storage लेती है।
- Complexity:
बहुत ज्यादा views database को complex बना सकते हैं।
Examples of Views in SQL in Hindi
नीचे कुछ practical examples दिए गए हैं जो exam और real-world दोनों में उपयोगी हैं:
---Example 1: Simple View
CREATE VIEW EmployeeView AS SELECT Name, Salary FROM Employee;---
Example 2: View with Condition
CREATE VIEW HighSalaryEmployees AS SELECT Name, Salary FROM Employee WHERE Salary > 50000;---
Example 3: Join View
CREATE VIEW EmpDeptView AS SELECT e.Name, d.DepartmentName FROM Employee e JOIN Department d ON e.DeptID = d.ID;---
Example 4: Updating View
UPDATE EmployeeView SET Salary = 60000 WHERE Name = 'Rahul';---
Example 5: Dropping View
DROP VIEW EmployeeView;---