Q. What is the Difference between Data and Information?
In English
Data | Information |
---|---|
Raw facts and figures. | Processed and organized data. |
Has no clear meaning on its own. | Has meaning and purpose. |
Example: numbers, symbols, names. | Example: student marks converted into result. |
Can be in the form of text, numbers, images, or audio. | Always useful for decision-making. |
Collected from various sources. | Generated after processing data. |
May contain errors or redundancy. | Usually accurate and summarized. |
Cannot help in decision-making directly. | Helps in decision-making. |
Input for processing. | Output of processing. |
हिन्दी में
डेटा | इन्फॉर्मेशन |
---|---|
कच्चे तथ्य और आँकड़े। | संसाधित और व्यवस्थित डेटा। |
अपने आप में कोई स्पष्ट अर्थ नहीं। | अर्थपूर्ण और उद्देश्यपूर्ण होता है। |
उदाहरण: संख्या, चिन्ह, नाम। | उदाहरण: विद्यार्थियों के अंक से बना परिणाम। |
टेक्स्ट, संख्या, इमेज या ऑडियो के रूप में हो सकता है। | हमेशा निर्णय लेने में सहायक। |
विभिन्न स्रोतों से इकट्ठा किया जाता है। | डेटा प्रोसेस करने के बाद बनता है। |
इसमें गलती या दोहराव हो सकता है। | आमतौर पर सही और संक्षिप्त होता है। |
सीधे निर्णय लेने में मददगार नहीं। | निर्णय लेने में मददगार। |
प्रोसेसिंग के लिए इनपुट। | प्रोसेसिंग का आउटपुट। |
Q. What is Database?
In English
A database is an organized collection of data that can be easily accessed, managed, and updated. It stores data in a structured form so that it can be used quickly and efficiently. Databases are used in banks, schools, offices, hospitals, and almost every field.
- Stores large amount of data systematically.
- Makes searching, updating, and deleting data easy.
- Provides security and reduces data duplication.
- Managed by Database Management System (DBMS).
- Examples: MySQL, Oracle, MS Access.
हिन्दी में
डेटाबेस एक संगठित डाटा का संग्रह है, जिसे आसानी से एक्सेस, प्रबंधित और अपडेट किया जा सकता है। इसमें डाटा को व्यवस्थित रूप से रखा जाता है ताकि उसे जल्दी और प्रभावी ढंग से उपयोग किया जा सके। डेटाबेस का प्रयोग बैंक, स्कूल, दफ्तर, अस्पताल और लगभग हर क्षेत्र में होता है।
- बड़े पैमाने पर डाटा को व्यवस्थित रूप से संग्रह करता है।
- डाटा को खोजना, बदलना और हटाना आसान बनाता है।
- सुरक्षा प्रदान करता है और डाटा की पुनरावृत्ति कम करता है।
- डेटाबेस मैनेजमेंट सिस्टम (DBMS) द्वारा प्रबंधित किया जाता है।
- उदाहरण: MySQL, Oracle, MS Access।
Q. What is RDBMS and its Advantages and Disadvantages?
In English
RDBMS stands for Relational Database Management System. It stores data in the form of tables (rows and columns) and allows relationships between them. It is widely used in modern applications like banking, education, business, etc. Examples are MySQL, Oracle, SQL Server.
Advantages:
- Stores data in table format, easy to understand.
- Maintains relationships between different data.
- Reduces data redundancy.
- Provides data security and integrity.
- Supports multiple users at the same time.
- Easy to update, search, and retrieve data.
Disadvantages:
- Complex to set up and maintain.
- Requires more memory and resources.
- Expensive compared to simple database systems.
- Performance may be slow for very large data if not managed properly.
हिन्दी में
RDBMS का पूरा नाम है Relational Database Management System। इसमें डेटा को तालिकाओं (rows और columns) के रूप में संग्रहित किया जाता है और अलग-अलग तालिकाओं के बीच संबंध बनाए जाते हैं। इसका उपयोग बैंकिंग, शिक्षा, व्यापार आदि क्षेत्रों में होता है। उदाहरण: MySQL, Oracle, SQL Server।
फायदे:
- डेटा को टेबल के रूप में संग्रहित करता है, समझना आसान।
- अलग-अलग डेटा के बीच संबंध बनाए रखता है।
- डेटा की पुनरावृत्ति कम करता है।
- डेटा की सुरक्षा और शुद्धता प्रदान करता है।
- एक ही समय में कई उपयोगकर्ताओं का समर्थन करता है।
- डेटा को बदलना, खोजना और प्राप्त करना आसान।
नुकसान:
- सेटअप और प्रबंधन जटिल।
- अधिक मेमोरी और संसाधनों की ज़रूरत।
- साधारण डेटाबेस की तुलना में महंगा।
- बहुत बड़े डेटा पर सही ढंग से प्रबंधन न होने पर धीमा हो सकता है।
Q. Difference between Traditional File System and DBMS
In English
Traditional File System | DBMS (Database Management System) |
---|---|
Stores data in separate files. | Stores data in structured databases. |
Data is scattered and difficult to manage. | Data is centralized and well managed. |
High data redundancy (repetition). | Low data redundancy. |
Security is very less. | Provides strong data security. |
Searching data is slow. | Searching data is fast. |
Difficult to update or modify data. | Easy to update and modify data. |
Backup and recovery not easy. | Provides backup and recovery options. |
Supports single user mostly. | Supports multiple users at the same time. |
हिन्दी में
पारंपरिक फ़ाइल सिस्टम | DBMS (डेटाबेस मैनेजमेंट सिस्टम) |
---|---|
डेटा अलग-अलग फ़ाइलों में संग्रहित होता है। | डेटा संरचित डेटाबेस में संग्रहित होता है। |
डेटा बिखरा हुआ और प्रबंधन कठिन। | डेटा केंद्रीकृत और व्यवस्थित। |
डेटा की पुनरावृत्ति अधिक। | डेटा की पुनरावृत्ति कम। |
सुरक्षा बहुत कम। | मज़बूत डेटा सुरक्षा प्रदान करता है। |
डेटा खोजना धीमा। | डेटा खोजना तेज़। |
डेटा अपडेट या बदलना कठिन। | डेटा अपडेट या बदलना आसान। |
बैकअप और रिकवरी आसान नहीं। | बैकअप और रिकवरी की सुविधा देता है। |
ज़्यादातर एक ही उपयोगकर्ता का समर्थन करता है। | एक साथ कई उपयोगकर्ताओं का समर्थन करता है। |
Q. What are the Three Tier Structure of DBMS?
In English
The three-tier structure of DBMS divides the database system into three layers to provide abstraction, security, and efficient management.
1. Presentation Tier (External Level):
- Closest to the user.
- Shows only the required data in a simple format.
- Hides the internal details.
- Example: A student sees only his marksheet on a portal, not the whole database.
2. Application Tier (Conceptual Level):
- Acts as a bridge between user and database.
- Defines the structure of the whole database.
- Manages relationships, rules, and security.
- Example: The education system stores how students, subjects, and marks are related.
3. Database Tier (Internal Level):
- Lowest level of abstraction.
- Deals with physical storage of data.
- Manages indexing, performance, and storage space.
- Example: How the marks of students are stored in hard disk using rows, columns, and indexing.
हिन्दी में
DBMS की three-tier संरचना डेटाबेस को तीन स्तरों में बाँटती है ताकि सुरक्षा, अमूर्तता और कुशल प्रबंधन हो सके।
1. प्रस्तुति स्तर (External Level):
- यह उपयोगकर्ता के सबसे पास होता है।
- केवल आवश्यक डेटा को सरल रूप में दिखाता है।
- आंतरिक विवरण को छिपाता है।
- उदाहरण: छात्र पोर्टल पर सिर्फ अपना मार्कशीट देखता है, पूरा डेटाबेस नहीं।
2. अनुप्रयोग स्तर (Conceptual Level):
- उपयोगकर्ता और डेटाबेस के बीच सेतु का काम करता है।
- पूरे डेटाबेस की संरचना को परिभाषित करता है।
- संबंध, नियम और सुरक्षा को संभालता है।
- उदाहरण: शिक्षा प्रणाली में यह परिभाषित करता है कि छात्र, विषय और अंक आपस में कैसे जुड़े हैं।
3. डेटाबेस स्तर (Internal Level):
- यह सबसे निचला स्तर होता है।
- डेटा का भौतिक भंडारण करता है।
- इंडेक्सिंग, प्रदर्शन और संग्रहण का प्रबंधन करता है।
- उदाहरण: छात्रों के अंक हार्ड डिस्क में rows, columns और indexing द्वारा कैसे संग्रहित होते हैं।
Q. Who is DBA and What are Different Roles and Responsibilities of DBA?
In English
A DBA (Database Administrator) is a person responsible for managing, maintaining, and securing the database system. DBA ensures smooth functioning of the database for all users.
Roles and Responsibilities of DBA:
- Database Design: Creates database structure (tables, relationships, constraints).
- Database Security: Provides access rights and prevents unauthorized use.
- Backup and Recovery: Takes regular backups and restores data in case of failure.
- Performance Monitoring: Ensures queries run fast and database works efficiently.
- Data Integrity: Maintains accuracy and consistency of data.
- User Management: Creates and manages user accounts.
- Database Upgrades: Installs new versions and applies patches.
- Troubleshooting: Solves problems like crashes, corruption, or slow performance.
हिन्दी में
DBA (Database Administrator) वह व्यक्ति है जो डेटाबेस सिस्टम का प्रबंधन, देखभाल और सुरक्षा करता है। DBA यह सुनिश्चित करता है कि सभी उपयोगकर्ताओं के लिए डेटाबेस सही और सुचारू रूप से कार्य करे।
DBA की भूमिकाएँ और ज़िम्मेदारियाँ:
- डेटाबेस डिज़ाइन: डेटाबेस की संरचना (टेबल्स, संबंध, constraints) बनाता है।
- डेटाबेस सुरक्षा: उपयोगकर्ताओं को सही अधिकार देता है और अनधिकृत पहुँच रोकता है।
- बैकअप और रिकवरी: नियमित रूप से बैकअप लेता है और खराबी पर डेटा वापस लाता है।
- प्रदर्शन निगरानी: यह सुनिश्चित करता है कि queries तेज़ चलें और डेटाबेस कुशलता से काम करे।
- डेटा अखंडता: डेटा की शुद्धता और स्थिरता बनाए रखता है।
- उपयोगकर्ता प्रबंधन: यूज़र अकाउंट बनाता और नियंत्रित करता है।
- डेटाबेस अपग्रेड: नए संस्करण और patches इंस्टॉल करता है।
- समस्या समाधान: database crash, corruption या slow performance जैसी समस्याओं को हल करता है।
Q. What do you mean by SQL? What are Characteristics of SQL?
In English
SQL (Structured Query Language) is a standard language used to store, manage, and retrieve data in a relational database. It is widely used in almost all database systems like MySQL, Oracle, and SQL Server.
Characteristics of SQL:
- Simple Language: Easy to learn and use with simple English-like commands.
- Data Definition: Allows creating, modifying, and deleting database objects like tables.
- Data Manipulation: Provides commands to insert, update, delete, and retrieve data.
- Data Control: Manages user permissions and access rights.
- Portability: SQL works with different database systems.
- Interactive: Provides quick responses to queries.
- Standardized: Accepted as an international standard by ANSI and ISO.
- Supports Transactions: Ensures data accuracy with commit and rollback features.
हिन्दी में
SQL (Structured Query Language) एक मानक भाषा है जिसका उपयोग रिलेशनल डेटाबेस में डेटा को संग्रहित, प्रबंधित और प्राप्त करने के लिए किया जाता है। इसका प्रयोग लगभग सभी डेटाबेस सिस्टम जैसे MySQL, Oracle, SQL Server में होता है।
SQL की विशेषताएँ:
- सरल भाषा: सीखने और उपयोग करने में आसान, साधारण अंग्रेज़ी जैसे commands।
- डेटा परिभाषा: डेटाबेस ऑब्जेक्ट जैसे टेबल बनाना, बदलना और हटाना।
- डेटा प्रबंधन: डेटा को insert, update, delete और retrieve करने की सुविधा।
- डेटा नियंत्रण: उपयोगकर्ताओं के अधिकार और permissions नियंत्रित करता है।
- पोर्टेबिलिटी: अलग-अलग डेटाबेस सिस्टम पर काम करता है।
- इंटरैक्टिव: queries के तेज़ जवाब देता है।
- मानकीकृत: ANSI और ISO द्वारा अंतर्राष्ट्रीय मानक के रूप में स्वीकार।
- ट्रांज़ैक्शन समर्थन: commit और rollback से डेटा की शुद्धता सुनिश्चित करता है।
Q. What are Different Datatypes in SQL?
In English
In SQL, datatypes define the type of data that can be stored in a column of a table. Each datatype specifies the kind of values like numbers, characters, or dates.
Different Datatypes in SQL:
- INT / INTEGER: Stores whole numbers (e.g., 10, -25).
- FLOAT / DOUBLE / REAL: Stores decimal or floating-point numbers (e.g., 12.5, 3.141).
- CHAR(n): Stores fixed-length character strings (e.g., ‘YES’, ‘NO’).
- VARCHAR(n): Stores variable-length character strings (e.g., ‘Hello’, ‘OpenAI’).
- TEXT: Stores long text values.
- DATE: Stores calendar dates (YYYY-MM-DD).
- TIME: Stores time (HH\:MM\:SS).
- DATETIME / TIMESTAMP: Stores both date and time together.
- BOOLEAN: Stores logical values TRUE or FALSE.
हिन्दी में
SQL में डेटा टाइप्स यह तय करते हैं कि किसी टेबल के कॉलम में किस प्रकार का डेटा संग्रहित किया जा सकता है। हर डेटा टाइप अलग-अलग प्रकार के मान जैसे संख्या, अक्षर या तारीख को दर्शाता है।
SQL में विभिन्न डेटा टाइप्स:
- INT / INTEGER: पूर्णांक संख्या संग्रहित करता है (जैसे 10, -25)।
- FLOAT / DOUBLE / REAL: दशमलव या floating-point संख्या संग्रहित करता है (जैसे 12.5, 3.141)।
- CHAR(n): निश्चित लंबाई वाले अक्षर संग्रहित करता है (जैसे ‘YES’, ‘NO’)।
- VARCHAR(n): बदलती लंबाई वाले अक्षर संग्रहित करता है (जैसे ‘Hello’, ‘OpenAI’)।
- TEXT: लंबा टेक्स्ट डेटा संग्रहित करता है।
- DATE: कैलेंडर तिथि संग्रहित करता है (YYYY-MM-DD)।
- TIME: समय संग्रहित करता है (HH\:MM\:SS)।
- DATETIME / TIMESTAMP: तिथि और समय दोनों संग्रहित करता है।
- BOOLEAN: तार्किक मान TRUE या FALSE संग्रहित करता है।
Q. Difference Between CHAR and VARCHAR Data Types
In English
CHAR | VARCHAR |
---|---|
Stores fixed-length character strings. | Stores variable-length character strings. |
Length is always the same, unused space is filled with spaces. | Length depends on the actual number of characters entered. |
Faster in performance because size is fixed. | Slower compared to CHAR as it handles varying length. |
Wastes memory if data is smaller than defined size. | Saves memory as it uses only required space. |
Example: CHAR(10) will always store 10 characters (e.g., ‘CAT ‘). | Example: VARCHAR(10) stores only actual characters (e.g., ‘CAT’). |
हिन्दी में
CHAR | VARCHAR |
---|---|
निश्चित लंबाई वाले अक्षर संग्रहित करता है। | बदलती लंबाई वाले अक्षर संग्रहित करता है। |
लंबाई हमेशा समान रहती है, खाली जगह spaces से भर दी जाती है। | लंबाई केवल डाले गए अक्षरों पर निर्भर करती है। |
प्रदर्शन तेज़ होता है क्योंकि आकार निश्चित है। | CHAR की तुलना में थोड़ा धीमा क्योंकि यह बदलती लंबाई संभालता है। |
यदि डेटा छोटा है तो मेमोरी व्यर्थ जाती है। | मेमोरी बचाता है क्योंकि केवल ज़रूरी जगह लेता है। |
उदाहरण: CHAR(10) हमेशा 10 अक्षर रखेगा (जैसे ‘CAT ‘)। | उदाहरण: VARCHAR(10) केवल वास्तविक अक्षर रखेगा (जैसे ‘CAT’)। |
Q. What do you mean by Constraints?
In English
In SQL, constraints are rules applied on columns of a table to ensure accuracy, validity, and reliability of data. They restrict the type of data that can be stored in a table.
Types of Constraints:
- NOT NULL: Ensures a column cannot have NULL value.
- UNIQUE: Ensures all values in a column are unique.
- PRIMARY KEY: Uniquely identifies each record in a table (NOT NULL + UNIQUE).
- FOREIGN KEY: Maintains relationship between two tables.
- CHECK: Ensures values meet specific conditions.
- DEFAULT: Provides a default value if no value is specified.
हिन्दी में
SQL में constraints वे नियम होते हैं जो किसी टेबल के कॉलम पर लगाए जाते हैं ताकि डेटा सही, वैध और भरोसेमंद रहे। ये नियंत्रित करते हैं कि टेबल में किस प्रकार का डेटा संग्रहित हो सकता है।
Constraints के प्रकार:
- NOT NULL: कॉलम में NULL मान नहीं हो सकता।
- UNIQUE: कॉलम के सभी मान अलग-अलग होने चाहिए।
- PRIMARY KEY: हर रिकॉर्ड को uniquely पहचानता है (NOT NULL + UNIQUE)।
- FOREIGN KEY: दो टेबल के बीच संबंध बनाए रखता है।
- CHECK: यह सुनिश्चित करता है कि मान विशेष शर्त पूरी करें।
- DEFAULT: यदि कोई मान न दिया जाए तो डिफ़ॉल्ट मान देता है।
Q. What is Domain Integrity Constraint?
In English
A Domain Integrity Constraint ensures that the values entered in a column are valid and within a defined range or type. It restricts the type, format, or range of values that can be stored in a column.
Examples:
- Age column should accept only numbers between 1 and 120.
- Gender column should allow only ‘Male’, ‘Female’, or ‘Other’.
- Date of Birth column must be in valid date format.
This helps in maintaining correctness and validity of data in a database.
हिन्दी में
Domain Integrity Constraint यह सुनिश्चित करता है कि किसी कॉलम में डाले गए मान सही हों और एक निश्चित सीमा या प्रकार के भीतर हों। यह मानों के प्रकार, प्रारूप या सीमा को नियंत्रित करता है।
उदाहरण:
- Age कॉलम में केवल 1 से 120 के बीच की संख्या होनी चाहिए।
- Gender कॉलम में केवल ‘Male’, ‘Female’ या ‘Other’ की अनुमति हो।
- Date of Birth कॉलम में मान्य तारीख का प्रारूप होना चाहिए।
यह डेटाबेस में डेटा की शुद्धता और वैधता बनाए रखने में मदद करता है।
Q. What is Referential Integrity Constraint?
In English
A Referential Integrity Constraint ensures that the relationship between two tables remains consistent. It is applied using a Foreign Key. It makes sure that a value in one table corresponds to a valid value in another table.
Examples:
- If a
Student
table has aClass_ID
as foreign key, then that value must exist in theClass
table. - If a record in the parent table is deleted, related child records must be handled (either deleted or restricted).
This avoids invalid references and maintains consistency between tables.
हिन्दी में
Referential Integrity Constraint यह सुनिश्चित करता है कि दो टेबलों के बीच संबंध सही और सुसंगत रहें। इसे Foreign Key के द्वारा लागू किया जाता है। यह सुनिश्चित करता है कि एक टेबल का मान दूसरी टेबल के मान से मेल खाए।
उदाहरण:
- यदि
Student
टेबल मेंClass_ID
foreign key है, तो वह मानClass
टेबल में मौजूद होना चाहिए। - यदि parent टेबल से कोई रिकॉर्ड हटाया जाता है, तो उससे जुड़े child रिकॉर्ड को या तो हटाना होगा या रोका जाएगा।
इससे गलत references नहीं बनते और टेबलों में consistency बनी रहती है।
Q. What do you mean by DML, DDL, DCL, TCL?
In English
In SQL, commands are divided into different categories based on their purpose.
- DDL (Data Definition Language):
Used to define and manage database structure.
Examples:CREATE
,ALTER
,DROP
,TRUNCATE
. - DML (Data Manipulation Language):
Used to insert, update, delete, and retrieve data.
Examples:INSERT
,UPDATE
,DELETE
,SELECT
. - DCL (Data Control Language):
Used to control access and permissions of users.
Examples:GRANT
,REVOKE
. - TCL (Transaction Control Language):
Used to manage transactions and maintain data integrity.
Examples:COMMIT
,ROLLBACK
,SAVEPOINT
.
हिन्दी में
SQL में commands को उनके उपयोग के आधार पर अलग-अलग भागों में बाँटा गया है।
- DDL (Data Definition Language):
डेटाबेस की संरचना बनाने और प्रबंधित करने के लिए।
उदाहरण:CREATE
,ALTER
,DROP
,TRUNCATE
। - DML (Data Manipulation Language):
डेटा जोड़ने, बदलने, हटाने और प्राप्त करने के लिए।
उदाहरण:INSERT
,UPDATE
,DELETE
,SELECT
। - DCL (Data Control Language):
उपयोगकर्ताओं की पहुँच और permissions नियंत्रित करने के लिए।
उदाहरण:GRANT
,REVOKE
। - TCL (Transaction Control Language):
ट्रांज़ैक्शन प्रबंधित करने और डेटा की शुद्धता बनाए रखने के लिए।
उदाहरण:COMMIT
,ROLLBACK
,SAVEPOINT
।
Q. What do you mean by Table? How to Create Table in SQL?
In English
A Table in SQL is a collection of data organized in rows and columns. Each row represents a record, and each column represents a field or attribute of that record. Tables are the basic building blocks of a database.
Example: A Student
table can have columns like Roll_No
, Name
, Class
, and Marks
.
Creating a Table in SQL:
CREATE TABLE Student (
Roll_No INT PRIMARY KEY,
Name VARCHAR(50),
Class VARCHAR(20),
Marks INT
);
This command creates a table named Student
with four columns.
हिन्दी में
SQL में Table डेटा का संग्रह है जिसे rows और columns के रूप में संगठित किया जाता है। हर row एक रिकॉर्ड को दर्शाता है और हर column उस रिकॉर्ड के गुण (attribute) को। टेबल डेटाबेस की मूल इकाई होती है।
उदाहरण: Student
टेबल में कॉलम हो सकते हैं – Roll_No
, Name
, Class
, और Marks
।
SQL में Table बनाना:
CREATE TABLE Student (
Roll_No INT PRIMARY KEY,
Name VARCHAR(50),
Class VARCHAR(20),
Marks INT
);
यह command Student
नाम का table बनाएगा जिसमें चार कॉलम होंगे।
Q. What is Function of SELECT Command?
In English
The SELECT command in SQL is used to retrieve data from one or more tables in a database. It allows users to view specific columns, rows, or apply conditions to filter data.
Functions of SELECT command:
- Retrieves all or selected columns from a table.
- Filters records using
WHERE
clause. - Sorts data using
ORDER BY
. - Combines data from multiple tables using
JOIN
. - Performs calculations using aggregate functions like
SUM()
,AVG()
,COUNT()
. - Groups records using
GROUP BY
.
Example:
SELECT Name, Marks FROM Student WHERE Class = '12th';
This query shows names and marks of students from class 12th.
हिन्दी में
SQL में SELECT command का उपयोग डेटाबेस की एक या अधिक टेबल से डेटा प्राप्त करने के लिए किया जाता है। इससे उपयोगकर्ता विशेष कॉलम, पंक्तियाँ या शर्त लगाकर डेटा देख सकते हैं।
SELECT command के कार्य:
- टेबल से सभी या कुछ चुने हुए कॉलम निकालना।
WHERE
clause से रिकॉर्ड फ़िल्टर करना।ORDER BY
से डेटा को क्रमबद्ध करना।- कई टेबलों से डेटा जोड़ना (
JOIN
के द्वारा)। SUM()
,AVG()
,COUNT()
जैसे aggregate functions से गणना करना।GROUP BY
से रिकॉर्ड को समूह में बाँटना।
उदाहरण:
SELECT Name, Marks FROM Student WHERE Class = '12th';
यह query केवल 12वीं कक्षा के छात्रों के नाम और अंक दिखाएगी।
Q. How can you insert rows in a table?
In English
In SQL, we use the INSERT INTO
command to add new rows of data into a table.
Methods to insert rows:
- Insert values into all columns
INSERT INTO Student VALUES (1, 'Rahul', '12th', 85);
👉 This will insert a new row in the Student table with RollNo = 1, Name = Rahul, Class = 12th, Marks = 85.
- Insert values into selected columns
INSERT INTO Student (RollNo, Name, Marks) VALUES (2, 'Anita', 90);
👉 Here, only RollNo, Name, and Marks are inserted. Class will remain NULL if not given.
- Insert multiple rows at once
INSERT INTO Student (RollNo, Name, Class, Marks)
VALUES
(3, 'Sohan', '11th', 78),
(4, 'Meena', '12th', 92);
👉 This will insert two rows together.
हिन्दी में
SQL में किसी टेबल में नई पंक्ति (row) जोड़ने के लिए INSERT INTO
command का उपयोग किया जाता है।
Rows insert करने के तरीके:
- सभी कॉलम में मान डालना
INSERT INTO Student VALUES (1, 'Rahul', '12th', 85);
👉 यह Student टेबल में एक नई पंक्ति जोड़ देगा।
- चुने हुए कॉलम में मान डालना
INSERT INTO Student (RollNo, Name, Marks) VALUES (2, 'Anita', 90);
👉 यहाँ Class नहीं दी गई है, तो वह NULL रहेगी।
- एक साथ कई rows डालना
INSERT INTO Student (RollNo, Name, Class, Marks)
VALUES
(3, 'Sohan', '11th', 78),
(4, 'Meena', '12th', 92);
👉 यह दो rows एक साथ insert करेगा।
Q. What is the use of DISTINCT clause in SELECT statement?
In English
- The DISTINCT clause in SQL is used to remove duplicate values from the result set of a query.
- It ensures that only unique values are returned.
Syntax:
SELECT DISTINCT column_name FROM table_name;
Example:
Suppose we have a table Student:
RollNo | Name | Class |
---|---|---|
1 | Rahul | 12th |
2 | Anita | 11th |
3 | Sohan | 12th |
4 | Meena | 10th |
5 | Rahul | 12th |
👉 Query:
SELECT DISTINCT Name FROM Student;
👉 Output:
Name |
---|
Rahul |
Anita |
Sohan |
Meena |
Here, Rahul appeared twice in the table but only once in the result because of DISTINCT.
हिन्दी में
- SQL में DISTINCT clause का उपयोग duplicate (दोहराए हुए) मानों को हटाने के लिए किया जाता है।
- यह केवल unique values ही वापस करता है।
Syntax:
SELECT DISTINCT column_name FROM table_name;
उदाहरण:
Student टेबल में ऊपर दिए गए डाटा से अगर हम चलाएँ:
SELECT DISTINCT Name FROM Student;
👉 परिणाम:
Name |
---|
Rahul |
Anita |
Sohan |
Meena |
यहाँ Rahul दो बार था, लेकिन परिणाम में केवल एक बार आया क्योंकि DISTINCT लगाया गया है।
Q. What is the purpose of WHERE clause with SELECT statement?
In English
- The WHERE clause in SQL is used to filter records from a table.
- It is used with the SELECT statement to get only those rows which meet a specific condition.
- Without WHERE, all rows of the table are returned.
Syntax:
SELECT column_name FROM table_name WHERE condition;
Example:
Suppose we have a table Student:
RollNo | Name | Class | Marks |
---|---|---|---|
1 | Rahul | 12th | 85 |
2 | Anita | 11th | 70 |
3 | Sohan | 12th | 90 |
4 | Meena | 10th | 60 |
SELECT Name, Marks FROM Student WHERE Marks > 75;
Output:
Name | Marks |
---|---|
Rahul | 85 |
Sohan | 90 |
हिन्दी में
- SQL में WHERE clause का उपयोग टेबल से records को filter करने के लिए किया जाता है।
- यह SELECT statement के साथ प्रयोग होता है ताकि केवल वही rows वापस मिलें जो condition को पूरा करती हैं।
- अगर WHERE नहीं लगाया जाता, तो पूरी टेबल की rows वापस आती हैं।
Syntax:
SELECT column_name FROM table_name WHERE condition;
उदाहरण:
ऊपर दिए गए Student टेबल से:
SELECT Name, Marks FROM Student WHERE Marks > 75;
परिणाम:
Name | Marks |
---|---|
Rahul | 85 |
Sohan | 90 |
Q. What is the function of ORDER BY clause?
In English
- The ORDER BY clause in SQL is used to arrange the result set of a query in ascending or descending order.
- By default, it sorts data in ascending order (ASC).
- For descending order, we use the keyword DESC.
- It can be applied on one or more columns.
Syntax:
SELECT column_name FROM table_name ORDER BY column_name ASC|DESC;
Example:
Suppose we have a table Student:
RollNo | Name | Marks |
---|---|---|
1 | Rahul | 85 |
2 | Anita | 90 |
3 | Sohan | 75 |
4 | Meena | 95 |
5 | Ramesh | 80 |
SELECT Name, Marks FROM Student ORDER BY Marks DESC;
Output:
Name | Marks |
---|---|
Meena | 95 |
Anita | 90 |
Rahul | 85 |
Ramesh | 80 |
Sohan | 75 |
हिन्दी में
- SQL में ORDER BY clause का उपयोग query के result को ascending या descending order में व्यवस्थित करने के लिए किया जाता है।
- Default रूप से यह data को ascending order (ASC) में sort करता है।
- Descending order के लिए DESC keyword का प्रयोग किया जाता है।
- इसे एक या एक से अधिक columns पर लागू किया जा सकता है।
Syntax:
SELECT column_name FROM table_name ORDER BY column_name ASC|DESC;
उदाहरण:
ऊपर दिए गए Student टेबल से:
SELECT Name, Marks FROM Student ORDER BY Marks DESC;
परिणाम:
Name | Marks |
---|---|
Meena | 95 |
Anita | 90 |
Rahul | 85 |
Ramesh | 80 |
Sohan | 75 |
Q. What is the use of AND, OR and NOT operator in SQL?
In English
These operators are used in the WHERE clause to filter records based on conditions.
- AND → Returns records when all conditions are true.
- OR → Returns records when any one condition is true.
- NOT → Returns records when the condition is not true.
Syntax:
SELECT column_name FROM table_name WHERE condition1 AND/OR/NOT condition2;
Example (Student Table):
RollNo | Name | Marks | City |
---|---|---|---|
1 | Rahul | 85 | Delhi |
2 | Anita | 90 | Mumbai |
3 | Sohan | 75 | Delhi |
4 | Meena | 95 | Kolkata |
5 | Ramesh | 80 | Mumbai |
-- Using AND
SELECT Name, Marks FROM Student WHERE Marks > 80 AND City = 'Delhi';
Output: Rahul (85)
-- Using OR
SELECT Name, City FROM Student WHERE City = 'Delhi' OR City = 'Mumbai';
Output: Rahul, Anita, Sohan, Ramesh
-- Using NOT
SELECT Name, City FROM Student WHERE NOT City = 'Delhi';
Output: Anita, Meena, Ramesh
हिन्दी में
ये ऑपरेटर्स WHERE clause में conditions के आधार पर records को filter करने के लिए उपयोग होते हैं।
- AND → Record तभी मिलेगा जब सभी conditions सही हों।
- OR → Record तब मिलेगा जब कोई एक condition सही हो।
- NOT → Record तब मिलेगा जब condition सही न हो।
Syntax:
SELECT column_name FROM table_name WHERE condition1 AND/OR/NOT condition2;
उदाहरण (Student Table):
-- AND का प्रयोग
SELECT Name, Marks FROM Student WHERE Marks > 80 AND City = 'Delhi';
Result: Rahul (85)
-- OR का प्रयोग
SELECT Name, City FROM Student WHERE City = 'Delhi' OR City = 'Mumbai';
Result: Rahul, Anita, Sohan, Ramesh
-- NOT का प्रयोग
SELECT Name, City FROM Student WHERE NOT City = 'Delhi';
Result: Anita, Meena, Ramesh
Q. Why BETWEEN operator is used?
In English
The BETWEEN operator is used in SQL to filter records within a specific range of values. It works for numbers, text, and dates. The range includes both the starting and ending values.
Syntax:
SELECT column_name FROM table_name WHERE column_name BETWEEN value1 AND value2;
Example (Student Table):
RollNo | Name | Marks |
---|---|---|
1 | Rahul | 85 |
2 | Anita | 90 |
3 | Sohan | 75 |
4 | Meena | 95 |
5 | Ramesh | 60 |
SELECT Name, Marks FROM Student WHERE Marks BETWEEN 80 AND 90;
Output: Rahul (85), Anita (90)
हिन्दी में
BETWEEN operator का उपयोग SQL में records को एक निर्धारित सीमा (range) के अंदर लाने के लिए किया जाता है। यह numbers, text और dates पर काम करता है। इसमें शुरुआती और अंतिम दोनों values शामिल होती हैं।
Syntax:
SELECT column_name FROM table_name WHERE column_name BETWEEN value1 AND value2;
उदाहरण (Student Table):
SELECT Name, Marks FROM Student WHERE Marks BETWEEN 80 AND 90;
Result: Rahul (85), Anita (90)
Q. How can you remove a table in database?
In English
To remove a table from a database, the DROP TABLE command is used. This command permanently deletes the table along with all its data, structure, and indexes. Once removed, the table cannot be recovered unless backed up.
Syntax:
DROP TABLE table_name;
Example:
DROP TABLE Student;
This will delete the table named Student from the database.
हिन्दी में
डेटाबेस से किसी टेबल को हटाने के लिए DROP TABLE कमांड का प्रयोग किया जाता है। यह कमांड टेबल के सभी डेटा, संरचना और indexes को स्थायी रूप से हटा देता है। हटाने के बाद टेबल वापस नहीं मिल सकता जब तक उसका backup न हो।
Syntax:
DROP TABLE table_name;
उदाहरण:
DROP TABLE Student;
यह कमांड डेटाबेस से Student नाम की टेबल को हटा देगा।
Q. How can you create users in SQL?
In English
In SQL, new users are created using the CREATE USER command. This command allows the database administrator to add a new user account with a username and password. After creating a user, permissions must be granted for accessing the database.
Syntax:
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
Example:
CREATE USER 'john'@'localhost' IDENTIFIED BY 'john123';
This will create a new user john with password john123, who can access the database from the local system.
हिन्दी में
SQL में नया user बनाने के लिए CREATE USER कमांड का प्रयोग किया जाता है। यह कमांड डेटाबेस में नया यूज़र अकाउंट username और password के साथ जोड़ने के लिए होता है। यूज़र बनाने के बाद उसे database access करने के लिए permissions देनी पड़ती हैं।
Syntax:
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
उदाहरण:
CREATE USER 'john'@'localhost' IDENTIFIED BY 'john123';
यह कमांड एक नया user john बनाएगा जिसका password john123 होगा, और जो केवल local system से database access कर सकेगा।
Q. How can you delete user accounts in SQL?
In English
To delete a user account in SQL, the DROP USER command is used. This command removes the user and all their privileges from the database. Once deleted, the user can no longer access the database.
Syntax:
DROP USER 'username'@'host';
Example:
DROP USER 'john'@'localhost';
This will delete the user john who was created for the local system.
हिन्दी में
SQL में किसी user account को हटाने के लिए DROP USER कमांड का उपयोग किया जाता है। यह कमांड user और उसकी सभी privileges को database से हटा देता है। हटाने के बाद वह user database को access नहीं कर सकता।
Syntax:
DROP USER 'username'@'host';
उदाहरण:
DROP USER 'john'@'localhost';
यह कमांड john नाम के user को हटा देगा, जो local system से database access करता था।
Q. What is Database and Database Management System?
In English
Database:
A database is an organized collection of data that can be easily accessed, managed, and updated. Data is stored in tables (rows and columns). Example: Student records, Banking system, Library system.
Database Management System (DBMS):
DBMS is software that helps to create, manage, and operate a database. It allows storing, retrieving, updating, and securing data efficiently. Examples: MySQL, Oracle, MS Access, SQL Server.
Key Points:
- Database stores data in an organized way.
- DBMS is software to manage that database.
- DBMS provides data security, integrity, and sharing.
हिन्दी में
Database:
Database एक संगठित संग्रह (organized collection) है जिसमें डेटा को आसानी से access, manage और update किया जा सकता है। डेटा तालिकाओं (rows और columns) में संग्रहित होता है। उदाहरण: Student records, Banking system, Library system।
Database Management System (DBMS):
DBMS एक software है जो database को बनाने, प्रबंधित करने और चलाने में मदद करता है। इसके द्वारा डेटा को store, retrieve, update और सुरक्षित किया जा सकता है। उदाहरण: MySQL, Oracle, MS Access, SQL Server।
मुख्य बिंदु:
- Database डेटा को व्यवस्थित रूप से संग्रहित करता है।
- DBMS उस database को प्रबंधित करने वाला software है।
- DBMS डेटा की सुरक्षा, शुद्धता और sharing प्रदान करता है।
Q. What is Function? What are various kinds of functions in SQL?
In English
Function:
In SQL, a function is a pre-defined program that performs a specific task and returns a value. Functions help in simplifying queries, reducing complexity, and increasing reusability.
Kinds of Functions in SQL:
- Aggregate Functions
- These functions work on a collection (group) of rows and return a single summarized value.
- Commonly used in
SELECT
statements withGROUP BY
. - Examples:
SUM(column)
→ Returns the total of values in a column.AVG(column)
→ Returns the average of values.COUNT(column)
→ Returns the number of rows.MAX(column)
→ Returns the largest value.MIN(column)
→ Returns the smallest value.
2. Scalar Functions
- These functions work on a single value and return a single value.
- Mostly used for string, numeric, or date operations.
- Examples:
UCASE(text)
/UPPER(text)
→ Converts text to uppercase.LCASE(text)
/LOWER(text)
→ Converts text to lowercase.LEN(text)
/LENGTH(text)
→ Returns length of string.ROUND(number, decimals)
→ Rounds a number to specified decimals.NOW()
→ Returns current system date and time.
3.String Functions
- Used to manipulate or format strings.
- Examples:
CONCAT(str1, str2)
→ Joins two or more strings.SUBSTRING(str, start, length)
→ Extracts part of a string.TRIM(text)
→ Removes spaces from beginning and end of a string.
4.Date and Time Functions
- Used to perform operations on dates and time values.
- Examples:
CURDATE()
→ Returns current date.CURTIME()
→ Returns current time.DATEADD()
→ Adds a value to a date.DATEDIFF(date1, date2)
→ Finds difference between two dates.
हिन्दी में
Function:
SQL में function एक pre-defined प्रोग्राम होता है, जो किसी विशेष कार्य को करता है और एक value लौटाता है। Functions queries को आसान, छोटा और उपयोगी बनाते हैं।
SQL में Functions के प्रकार:
- Aggregate Functions
- ये functions rows के समूह (collection) पर काम करते हैं और एक summarized value लौटाते हैं।
- इन्हें
SELECT
के साथGROUP BY
में अधिक उपयोग किया जाता है। - उदाहरण:
SUM(column)
→ कॉलम के मानों का कुल जोड़ देता है।AVG(column)
→ औसत मान निकालता है।COUNT(column)
→ rows की गिनती करता है।MAX(column)
→ सबसे बड़ा मान देता है।MIN(column)
→ सबसे छोटा मान देता है।
- Scalar Functions
- ये functions एक single value पर काम करते हैं और एक value लौटाते हैं।
- इन्हें string, numeric और date operations में प्रयोग किया जाता है।
- उदाहरण:
UCASE(text)
/UPPER(text)
→ text को uppercase में बदलता है।LCASE(text)
/LOWER(text)
→ text को lowercase में बदलता है।LEN(text)
/LENGTH(text)
→ string की लंबाई देता है।ROUND(number, decimals)
→ संख्या को round करता है।NOW()
→ वर्तमान तारीख और समय देता है।
- String Functions
- Strings को manipulate या format करने के लिए उपयोग होते हैं।
- उदाहरण:
CONCAT(str1, str2)
→ दो या अधिक strings को जोड़ना।SUBSTRING(str, start, length)
→ string का हिस्सा निकालना।TRIM(text)
→ शुरुआत और अंत के spaces हटाना।
- Date और Time Functions
- तारीख और समय पर operations करने के लिए उपयोग होते हैं।
- उदाहरण:
CURDATE()
→ वर्तमान तारीख देता है।CURTIME()
→ वर्तमान समय देता है।DATEADD()
→ किसी तारीख में मान जोड़ना।DATEDIFF(date1, date2)
→ दो तारीखों का अंतर निकालना।