Skip to main content

SQL kya hai?

 


1. SQL kya hai?

Jawaab: SQL ka full form hai "Structured Query Language". Yeh ek aisi language hai jisse hum computer ko bol sakte hain ke database (jaise ek badi kitaab ya register jisme data hota hai) se kuch information nikaale, badle, ya naye data ko store kare. SQL zyada tar database manage karne ke liye use hoti hai, jaise MySQL aur SQL Server.


2. Primary Key kya hoti hai?

Jawaab: Primary Key ek aisa khaas column hota hai jo table ke har record ko unique banata hai, yaani har row alag hoti hai. Yeh key kabhi repeat nahi hoti aur NULL bhi nahi hoti. Jaise ek class mein har student ka alag roll number hota hai, waise hi Primary Key ek unique ID banati hai.


3. SQL mein Joins kya hote hain? Aur inke types batao.

Jawaab: Joins ka kaam do ya zyada tables ke records ko jodna hota hai. Jaise ek table mein students ke naam hain aur doosri mein unke marks, toh join se dono tables ke data ko ek saath dekh sakte hain.

  • INNER JOIN: Sirf wahi rows lata hai jo dono tables mein match karti hain.
  • LEFT JOIN: Sab rows left table se lata hai aur right table se matching rows leta hai. Agar match na ho toh NULL dikhata hai.
  • RIGHT JOIN: Sab rows right table se lata hai aur left table se matching rows leta hai. Agar match na ho toh NULL dikhata hai.
  • FULL JOIN: Sab rows lata hai chahe match ho ya nahi, aur match na hone par NULL show karta hai.

4. Foreign Key kya hoti hai?

Jawaab: Foreign Key ek column hai jo ek table ke Primary Key ko doosri table mein link karta hai. Yeh do tables ke beech ka rishtey (relationship) ko banata hai. Jaise agar students aur classes ki alag tables hain, toh Foreign Key se students aur classes ka connection bana sakte hain.


5. Self Join kya hota hai?

Jawaab: Self Join mein ek table ko usi table se join karte hain. Jaise ek employees ki table ho jisme har employee ka manager bhi hai, jo khud bhi employee hai. Self Join se hum yeh dekh sakte hain ke kaunsa employee kiske under kaam kar raha hai.


6. WHERE aur HAVING mein kya farq hai?

Jawaab:

  • WHERE Clause: Yeh rows ko filter karta hai bina data ko group kiye. SELECT, UPDATE, aur DELETE ke sath use hota hai.
  • HAVING Clause: Yeh aggregated records ko filter karta hai, yaani jab data ko group kiya gaya ho. Yeh zyada tar GROUP BY ke sath use hota hai.

7. Indexes kya hote hain?

Jawaab: Index ek khaas list hai jo database ko data jaldi dhundhne mein madad karti hai. Jaise kitaab ke pehle page par topics ki list hoti hai, waise hi index se rows jaldi mil jaati hain. Lekin, indexes ko bar-bar update karna padta hai jab data add ya delete hota hai.


8. DELETE aur TRUNCATE mein kya farq hai?

Jawaab:

  • DELETE: Specific rows ko delete karta hai jo WHERE clause mein di gayi condition ko match karti hain. Yeh slow hai kyunki yeh har row ko individually delete karta hai aur rollback ho sakta hai.
  • TRUNCATE: Saare rows ko ek saath delete karta hai bina condition ke aur rollback nahi ho sakta. Yeh delete se fast hota hai.

9. SQL mein Aggregate Functions kya hote hain? Kuch examples batao.

Jawaab: Aggregate functions data ko count ya total karne mein madad karte hain. Yeh ek single result dete hain. Kuch common aggregate functions hain:

  • COUNT: Rows ko gin leta hai.
  • SUM: Column mein values ka total nikalta hai.
  • AVG: Column mein values ka average nikalta hai.
  • MIN: Column ki minimum value batata hai.
  • MAX: Column ki maximum value batata hai.

10. SQL Injection kya hota hai aur ise kaise roka ja sakta hai?

Jawaab: SQL Injection ek tarika hai jisse ek attacker input field mein malicious (nuksan pohchane wala) SQL code daal kar database ka data chura sakta hai ya change kar sakta hai. Isse bachne ke liye:

  • Parameterized Queries aur Prepared Statements use karo.
  • Dynamic SQL ko avoid karo jo user input ko directly use kar raha ho.

Comments

Popular posts from this blog

Best Phones Under 20,000 INR

Best Phones Under 20,000 INR Best Phones Under 20,000 INR Finding a quality smartphone within a budget of 20,000 INR can be challenging, but several excellent options are available in this price range. Whether you’re looking for great performance, a solid camera, or long battery life, this list has you covered. Here are some of the best smartphones you can buy under 20,000 INR. 1. Xiaomi Redmi Note 12 Price: ₹16,499 The Xiaomi Redmi Note 12 offers a stunning display, impressive camera capabilities, and a powerful Snapdragon processor. With a large 5,000mAh battery, you can enjoy all-day usage without worrying about recharging. 2. Realme 10 Price: ₹17,999 The Realme 10 features a sleek design and a MediaTek Helio G99 processor that ensures smooth performance for gaming and multitasking. The 50MP dual-camera setup captures vibrant photos, making it a great choice for photography enthusiasts. 3. Samsung Gala...
5G vs. Wi-Fi 6: Which is Better for You? 5G vs. Wi-Fi 6: Which is Better for You? As technology evolves, the debate between 5G and Wi-Fi 6 becomes increasingly relevant. Both technologies promise faster internet speeds and improved connectivity, but they serve different purposes and use cases. In this article, we'll explore the unique features of each technology and help you determine which is better suited for your needs. Understanding the Basics 5G , the fifth generation of mobile networks, offers incredibly fast download and upload speeds, reduced latency, and the ability to connect more devices simultaneously. It is designed to provide seamless connectivity in urban areas and can support applications such as autonomous vehicles and smart cities. Wi-Fi 6 , on the other hand, is the latest iteration of wireless local area networks (WLAN). It brings enhanced performance in crowded environments, faster speeds, and im...

The Future of Artificial Intelligence

The Future of Artificial Intelligence The Future of Artificial Intelligence Artificial Intelligence (AI) has become one of the most transformative technologies of our time, reshaping industries and enhancing our daily lives. As we look towards the future, AI's potential seems limitless, promising advancements that could revolutionize everything from healthcare to transportation. 1. Healthcare Revolution AI is set to play a pivotal role in healthcare, with innovations in diagnostics, personalized medicine, and patient care. Machine learning algorithms can analyze vast amounts of medical data, leading to earlier and more accurate diagnoses. For instance, AI can assist in identifying diseases from medical imaging with remarkable precision. Additionally, AI-driven tools can tailor treatment plans to individual patients, taking into account genetic information and lifestyle factors. 2. Autonomou...