SQL के बेसिक इंटरव्यू सवाल: हिंदी में (SQL Basic Interview Questions: A Guide in Hindi)

SQL के बेसिक इंटरव्यू सवाल: हिंदी में (SQL Basic Interview Questions: A Guide in Hindi)

SQL (Structured Query Language) का उपयोग डेटाबेस मैनेजमेंट और डेटा को क्वेरी, मैनीपुलेट, और मॉडिफाई करने के लिए किया जाता है। अगर आप SQL सीख रहे हैं और इंटरव्यू की तैयारी कर रहे हैं, तो यह ब्लॉग पोस्ट आपके लिए है। इसमें हम SQL के कुछ बेसिक सवालों और उनके जवाबों पर चर्चा करेंगे जो अक्सर इंटरव्यू में पूछे जाते हैं।

SQL Basic Interview Questions

1. What is SQL? (SQL क्या है?)

Answer (उत्तर):
In English:
SQL (Structured Query Language) is a programming language used to interact with relational databases. It is used to query, insert, update, and delete data in databases.

In Hindi:
SQL (Structured Query Language) एक प्रोग्रामिंग भाषा है जिसका उपयोग रिलेशनल डेटाबेस के साथ इंटरैक्ट करने के लिए किया जाता है। इसका उपयोग डेटा को क्वेरी, इंसर्ट, अपडेट और डिलीट करने के लिए किया जाता है।


2. What are the different types of SQL commands? (SQL कमांड के प्रकार क्या हैं?)

Answer (उत्तर):
In English:
The different types of SQL commands are:

  • DDL (Data Definition Language): Commands like CREATE, ALTER, DROP.
  • DML (Data Manipulation Language): Commands like INSERT, UPDATE, DELETE.
  • DCL (Data Control Language): Commands like GRANT, REVOKE.
  • TCL (Transaction Control Language): Commands like COMMIT, ROLLBACK.
  • DQL (Data Query Language): Command like SELECT.

In Hindi:
SQL कमांड्स के विभिन्न प्रकार हैं:

  • DDL (डेटा डेफिनिशन लैंग्वेज): जैसे CREATE, ALTER, DROP
  • DML (डेटा मैनिपुलेशन लैंग्वेज): जैसे INSERT, UPDATE, DELETE
  • DCL (डेटा कंट्रोल लैंग्वेज): जैसे GRANT, REVOKE
  • TCL (ट्रांजैक्शन कंट्रोल लैंग्वेज): जैसे COMMIT, ROLLBACK
  • DQL (डेटा क्वेरी लैंग्वेज): जैसे SELECT

3. What is the difference between DELETE and TRUNCATE? (DELETE और TRUNCATE में क्या अंतर है?)

Answer (उत्तर):
In English:

  • DELETE: Removes specific rows from a table based on a condition. It can be rolled back.
  • TRUNCATE: Removes all rows from a table without a condition. It cannot be rolled back.

In Hindi:

  • DELETE: किसी टेबल से एक विशेष कंडीशन के आधार पर डेटा को हटाता है। इसे रिवर्स किया जा सकता है।
  • TRUNCATE: एक टेबल से सभी डेटा को बिना किसी कंडीशन के हटाता है। इसे रिवर्स नहीं किया जा सकता।

4. What is a Primary Key? (Primary Key क्या है?)

Answer (उत्तर):
In English:
A Primary Key is a column (or combination of columns) in a table that uniquely identifies each row. It cannot contain NULL values.

In Hindi:
Primary Key एक कॉलम (या कॉलम का संयोजन) है जो टेबल की प्रत्येक रो को यूनिकली पहचानता है। इसमें NULL वैल्यू नहीं हो सकती।


5. What is the difference between WHERE and HAVING clauses? (WHERE और HAVING क्लॉज में क्या अंतर है?)

Answer (उत्तर):
In English:

  • WHERE is used to filter rows before any grouping occurs.
  • HAVING is used to filter groups after grouping has been performed.

In Hindi:

  • WHERE का उपयोग ग्रुपिंग से पहले रो को फिल्टर करने के लिए किया जाता है।
  • HAVING का उपयोग ग्रुपिंग के बाद ग्रुप्स को फिल्टर करने के लिए किया जाता है।

6. What is the use of JOIN in SQL? (SQL में JOIN का उपयोग क्या है?)

Answer (उत्तर):
In English:
JOIN is used to retrieve data from multiple tables based on a related column. The types of JOINs are:

  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN
  • FULL OUTER JOIN

In Hindi:
JOIN का उपयोग एक से अधिक टेबल से डेटा प्राप्त करने के लिए किया जाता है जो किसी रिलेटेड कॉलम पर आधारित होता है। JOIN के प्रकार हैं:

  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN
  • FULL OUTER JOIN

7. What is normalization? (Normalization क्या है?)

Answer (उत्तर):
In English:
Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity. It involves dividing a database into multiple tables and defining relationships between them.

In Hindi:
Normalization डेटाबेस में डेटा को इस तरह व्यवस्थित करने की प्रक्रिया है जिससे डेटा की पुनरावृत्ति (redundancy) कम हो और डेटा की अखंडता (integrity) बेहतर हो। इसमें डेटाबेस को कई टेबल्स में विभाजित करना और उनके बीच संबंध बनाना शामिल है।

Q: How to find the nth highest salary in SQL? (SQL में nth highest salary कैसे निकालें?)

Answer (उत्तर):

In English:
You can find the nth highest salary using the LIMIT and OFFSET keywords or by using a subquery. Below are the most common methods:


1. Using LIMIT and OFFSET (MySQL)

SELECT DISTINCT salary 
FROM employees
ORDER BY salary DESC
LIMIT 1 OFFSET n-1;

2. Using Subquery (Standard SQL)

SELECT MAX(salary) 
FROM employees 
WHERE salary < (SELECT MAX(salary) 
                FROM employees);

3. Using DENSE_RANK() (SQL Server, Oracle, PostgreSQL)

SELECT salary 
FROM (
    SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) as rank
    FROM employees
) ranked
WHERE rank = n;

 

Q: What is the difference between VARCHAR and CHAR?

Answer:

  • CHAR: Fixed-length, always uses the defined size, suitable for predictable-length data like PIN codes.
  • VARCHAR: Variable-length, uses only required space, ideal for data with varying lengths like names or comments.

Example:
CHAR(10) stores “SQL” as 10 bytes (with padding).
VARCHAR(10) stores “SQL” as 3 bytes.

उत्तर:

  • CHAR: फिक्स्ड-लेंथ, हमेशा परिभाषित साइज लेता है, जैसे पिन कोड के लिए उपयुक्त।
  • VARCHAR: वैरिएबल-लेंथ, केवल आवश्यक स्पेस लेता है, जैसे नाम या कमेंट्स के लिए सही।

उदाहरण:
CHAR(10) “SQL” को 10 बाइट्स में स्टोर करेगा (स्पेस के साथ)।
VARCHAR(10) “SQL” को 3 बाइट्स में स्टोर करेगा।



Index