Introduction to SQL | SQL Basics, Features, SQL Commands (DDL, DML, DQL) and MySQL | Complete Notes | CBSE Class 11 Informatics Practices (2026–27)
Class 11 · Informatics Practices
Introduction to SQL | SQL Basics, Features, SQL Commands (DDL, DML, DQL) and MySQL
After understanding databases and the Relational Data Model, the next step is learning SQL (Structured Query Language). SQL is the standard language used to communicate with relational databases. It allows users to create databases, store data, retrieve information, update records, and manage database objects efficiently.
Almost every modern relational database system, including MySQL, Oracle, PostgreSQL, Microsoft SQL Server, and SQLite, supports SQL. Whether you are building a school management system, an online shopping website, or a banking application, SQL plays a vital role in managing data.
Learning Outcomes
After studying this chapter, you will be able to:
- Understand SQL and its importance.
- Identify the features and advantages of SQL.
- Learn different categories of SQL commands.
- Understand the role of MySQL.
- Follow the basic rules for writing SQL statements.
What is SQL?
SQL (Structured Query Language) is the standard language used to create, access, retrieve, update, and manage data stored in relational databases.
SQL is not a programming language. It is a database query language specially designed for working with relational databases.
Why Do We Need SQL?
A database stores a large amount of information. SQL provides an easy and efficient way to communicate with the database.
Using SQL, we can:
- Create databases.
- Create tables.
- Insert new records.
- Retrieve required data.
- Update existing records.
- Delete records.
- Modify database structures.
Features of SQL
| Feature | Description |
|---|---|
| Easy to Learn | Uses simple English-like commands. |
| Standard Language | Supported by almost all relational databases. |
| Powerful | Can perform data retrieval, insertion, updating, and deletion. |
| Portable | Works across different operating systems. |
| Efficient | Handles large volumes of data quickly. |
| Flexible | Can be used for simple as well as complex database operations. |
Advantages of SQL
- Simple syntax.
- Fast data retrieval.
- Easy database management.
- Supports multiple users.
- Highly secure.
- Industry-standard language.
- Works with many DBMS software.
Real-Life Applications of SQL
| Industry | Use of SQL |
|---|---|
| Schools | Managing student records and examination data. |
| Banks | Managing customer accounts and transactions. |
| Hospitals | Managing patient records and appointments. |
| E-commerce | Managing products, customers, and orders. |
| Airlines | Managing reservations and flight schedules. |
| Libraries | Managing books and member records. |
Example of SQL Commands
The following examples show how SQL is used to perform different tasks.
| Purpose | SQL Statement |
|---|---|
| Create a database | CREATE DATABASE School; |
| Create a table | CREATE TABLE Student (...); |
| Insert data | INSERT INTO Student VALUES (...); |
| Display data | SELECT * FROM Student; |
| Update data | UPDATE Student SET Marks=95; |
| Delete data | DELETE FROM Student; |
Categories of SQL Commands
SQL commands are grouped into different categories depending on the type of operation they perform.
| Category | Purpose |
|---|---|
| DDL | Defines and modifies database structures. |
| DML | Manipulates data stored in tables. |
| DQL | Retrieves data from tables. |
The next chapters discuss these command categories in detail.
Introduction to MySQL
MySQL is an open-source Relational Database Management System (RDBMS) that uses SQL to store, retrieve, and manage data.
MySQL is one of the world's most popular database management systems because it is fast, reliable, secure, and easy to use.
Applications of MySQL
- School Management Systems
- Online Shopping Websites
- Banking Applications
- Hospital Management Systems
- Library Management Systems
- Social Media Platforms
SQL Statement Rules
- Every SQL statement ends with a semicolon (;).
- SQL keywords are not case-sensitive.
- Table names and column names should be meaningful.
- Keywords are generally written in uppercase for better readability.
- Spaces improve readability but do not affect execution.
- Each SQL statement performs a specific task.
Example
SELECT * FROM Student;
This statement displays all records from the Student table.
Introduction to SQL | SQL Basics, Features, SQL Commands (DDL, DML, DQL) and MySQL
After understanding databases and the Relational Data Model, the next step is learning SQL (Structured Query Language). SQL is the standard language used to communicate with relational databases. It allows users to create databases, store data, retrieve information, update records, and manage database objects efficiently.
Almost every modern relational database system, including MySQL, Oracle, PostgreSQL, Microsoft SQL Server, and SQLite, supports SQL. Whether you are building a school management system, an online shopping website, or a banking application, SQL plays a vital role in managing data.
Learning Outcomes
After studying this chapter, you will be able to:
- Understand SQL and its importance.
- Identify the features and advantages of SQL.
- Learn different categories of SQL commands.
- Understand the role of MySQL.
- Follow the basic rules for writing SQL statements.
What is SQL?
SQL (Structured Query Language) is the standard language used to create, access, retrieve, update, and manage data stored in relational databases.
SQL is not a programming language. It is a database query language specially designed for working with relational databases.
Why Do We Need SQL?
A database stores a large amount of information. SQL provides an easy and efficient way to communicate with the database.
Using SQL, we can:
- Create databases.
- Create tables.
- Insert new records.
- Retrieve required data.
- Update existing records.
- Delete records.
- Modify database structures.
Features of SQL
| Feature | Description |
|---|---|
| Easy to Learn | Uses simple English-like commands. |
| Standard Language | Supported by almost all relational databases. |
| Powerful | Can perform data retrieval, insertion, updating, and deletion. |
| Portable | Works across different operating systems. |
| Efficient | Handles large volumes of data quickly. |
| Flexible | Can be used for simple as well as complex database operations. |
Advantages of SQL
- Simple syntax.
- Fast data retrieval.
- Easy database management.
- Supports multiple users.
- Highly secure.
- Industry-standard language.
- Works with many DBMS software.
Real-Life Applications of SQL
| Industry | Use of SQL |
|---|---|
| Schools | Managing student records and examination data. |
| Banks | Managing customer accounts and transactions. |
| Hospitals | Managing patient records and appointments. |
| E-commerce | Managing products, customers, and orders. |
| Airlines | Managing reservations and flight schedules. |
| Libraries | Managing books and member records. |
Example of SQL Commands
The following examples show how SQL is used to perform different tasks.
| Purpose | SQL Statement |
|---|---|
| Create a database | CREATE DATABASE School; |
| Create a table | CREATE TABLE Student (...); |
| Insert data | INSERT INTO Student VALUES (...); |
| Display data | SELECT * FROM Student; |
| Update data | UPDATE Student SET Marks=95; |
| Delete data | DELETE FROM Student; |
Categories of SQL Commands
SQL commands are grouped into different categories depending on the type of operation they perform.
| Category | Purpose |
|---|---|
| DDL | Defines and modifies database structures. |
| DML | Manipulates data stored in tables. |
| DQL | Retrieves data from tables. |
The next chapters discuss these command categories in detail.
Introduction to MySQL
MySQL is an open-source Relational Database Management System (RDBMS) that uses SQL to store, retrieve, and manage data.
MySQL is one of the world's most popular database management systems because it is fast, reliable, secure, and easy to use.
Applications of MySQL
- School Management Systems
- Online Shopping Websites
- Banking Applications
- Hospital Management Systems
- Library Management Systems
- Social Media Platforms
SQL Statement Rules
- Every SQL statement ends with a semicolon (;).
- SQL keywords are not case-sensitive.
- Table names and column names should be meaningful.
- Keywords are generally written in uppercase for better readability.
- Spaces improve readability but do not affect execution.
- Each SQL statement performs a specific task.
Example
SELECT * FROM Student;
This statement displays all records from the Student table.
SQL Command Categories in Detail
SQL commands are classified into different categories based on the type of operation they perform on a database.
| Category | Full Form | Purpose |
|---|---|---|
| DDL | Data Definition Language | Creates and modifies database objects. |
| DML | Data Manipulation Language | Inserts, updates, and deletes records. |
| DQL | Data Query Language | Retrieves data from database tables. |
1. DDL (Data Definition Language)
Data Definition Language (DDL) consists of SQL commands used to create, modify, and delete database objects such as databases and tables.
Common DDL Commands
| Command | Purpose |
|---|---|
| CREATE | Creates a database or table. |
| ALTER | Modifies the structure of a table. |
| DROP | Deletes a database or table. |
Examples
CREATE DATABASE School;
CREATE TABLE Student(
Roll_No INT,
Name VARCHAR(30)
);
DROP TABLE Student;
2. DML (Data Manipulation Language)
Data Manipulation Language (DML) consists of commands used to add, modify, and remove records stored in database tables.
Common DML Commands
| Command | Purpose |
|---|---|
| INSERT | Adds new records. |
| UPDATE | Modifies existing records. |
| DELETE | Removes records. |
Examples
INSERT INTO Student
VALUES(101,'Riya',92);
UPDATE Student
SET Marks=95
WHERE Roll_No=101;
DELETE FROM Student
WHERE Roll_No=101;
3. DQL (Data Query Language)
Data Query Language (DQL) consists of commands used to retrieve data from one or more tables.
The most commonly used DQL command is SELECT.
Example
SELECT * FROM Student;
The above command displays all records and all columns from the Student table.
Comparison of SQL Command Categories
| Feature | DDL | DML | DQL |
|---|---|---|---|
| Main Purpose | Defines database objects. | Manipulates data. | Retrieves data. |
| Works On | Database structure. | Table records. | Stored data. |
| Examples | CREATE, ALTER, DROP | INSERT, UPDATE, DELETE | SELECT |
SQL Keywords
Keywords are reserved words that have predefined meanings in SQL. They are used to perform specific database operations.
Common SQL Keywords
| Keyword | Purpose |
|---|---|
| SELECT | Retrieve data. |
| FROM | Specify the table. |
| WHERE | Apply conditions. |
| CREATE | Create a database or table. |
| INSERT | Insert records. |
| UPDATE | Modify records. |
| DELETE | Delete records. |
| DROP | Delete database objects. |
Rules for Writing SQL Statements
| Rule | Example |
|---|---|
| End every statement with a semicolon. | SELECT * FROM Student; |
| Keywords are not case-sensitive. | select and SELECT are both valid. |
| Use meaningful table names. | Student, Employee, Book |
| Use uppercase keywords. | SELECT, INSERT, UPDATE |
| Write one statement for one task. | Each command performs a specific operation. |
Solved Example 1
Identify the category of each SQL command.
| Command | Category |
|---|---|
| CREATE TABLE Student | DDL |
| INSERT INTO Student | DML |
| UPDATE Student | DML |
| DELETE FROM Student | DML |
| SELECT * FROM Student | DQL |
Solved Example 2
Question: Which SQL command is used to display all records from a table named Employee?
Answer:
SELECT * FROM Employee;
Common Errors
| Mistake | Correct Understanding |
|---|---|
| Forgetting the semicolon. | Every SQL statement should end with a semicolon. |
| Using CREATE to insert records. | CREATE defines objects; INSERT adds records. |
| Using DELETE to remove a table. | DELETE removes records, while DROP removes the table. |
| Assuming SQL keywords are case-sensitive. | SQL keywords are generally case-insensitive. |
| Using SELECT without FROM. | Normally, SELECT retrieves data from a specified table. |
Interview Corner
Q. What is the difference between DDL, DML, and DQL?
Answer:
- DDL creates or modifies database objects.
- DML inserts, updates, and deletes records.
- DQL retrieves data using the SELECT command.
Real-Life Applications of SQL
| Industry | How SQL is Used |
|---|---|
| Schools | Managing student records, attendance, marks, and fee details. |
| Banks | Maintaining customer accounts, transactions, and loan records. |
| Hospitals | Storing patient information, appointments, and medical history. |
| E-commerce | Managing products, customers, orders, and online payments. |
| Railways | Handling ticket reservations and passenger information. |
| Libraries | Managing books, members, and issue/return records. |
| Social Media | Managing user profiles, posts, comments, and messages. |
Solved Example 3
Identify the SQL Command Category.
| Statement | Answer |
|---|---|
| CREATE DATABASE School; | DDL |
| INSERT INTO Student VALUES(101,'Riya',92); | DML |
| UPDATE Student SET Marks=95; | DML |
| DELETE FROM Student; | DML |
| SELECT * FROM Student; | DQL |
Solved Example 4
Fill in the Blanks.
| Question | Answer |
|---|---|
| SQL stands for __________. | Structured Query Language |
| __________ command retrieves data. | SELECT |
| __________ command creates a table. | CREATE |
| __________ command inserts records. | INSERT |
| __________ is an open-source RDBMS. | MySQL |
Solved Example 5
Question:
A school wants to create a new database named SchoolDB. Which SQL command should be used?
Answer:
CREATE DATABASE SchoolDB;
Competency-Based Questions
- Explain why SQL is called the standard language for relational databases.
- A school wants to create a new table for storing student information. Which category of SQL commands will be used? Give reasons.
- Differentiate between DDL, DML, and DQL with one example of each.
- Why is MySQL one of the most popular database management systems?
- A bank wants to retrieve all customer records from its database. Which SQL command should be used? Explain your answer.
Multiple Choice Questions
- SQL stands for:
- (a) Structured Question Language
- (b) Structured Query Language
- (c) Simple Query Language
- (d) Standard Query Logic
- Which SQL command retrieves records from a table?
- (a) INSERT
- (b) UPDATE
- (c) SELECT
- (d) DELETE
- Which category does the CREATE command belong to?
- (a) DML
- (b) DDL
- (c) DQL
- (d) TCL
- Which command is used to insert records into a table?
- (a) CREATE
- (b) INSERT
- (c) SELECT
- (d) DROP
- Which SQL command modifies existing records?
- (a) SELECT
- (b) CREATE
- (c) UPDATE
- (d) DROP
- Which SQL command removes records from a table?
- (a) DROP
- (b) DELETE
- (c) SELECT
- (d) CREATE
- Which SQL command removes an entire table from the database?
- (a) DELETE
- (b) DROP
- (c) UPDATE
- (d) SELECT
- Which of the following is an example of an RDBMS?
- (a) Python
- (b) Windows
- (c) MySQL
- (d) HTML
- SQL keywords are generally:
- (a) Case-sensitive
- (b) Case-insensitive
- (c) Numeric only
- (d) Written only in lowercase
- Which SQL command category is used to retrieve data?
- (a) DDL
- (b) DML
- (c) DQL
- (d) DCL
Quick Revision
| Concept | Remember |
|---|---|
| SQL | Structured Query Language |
| DDL | Creates and modifies database objects. |
| DML | Inserts, updates, and deletes records. |
| DQL | Retrieves records using SELECT. |
| MySQL | Open-source Relational Database Management System. |
| SELECT | Displays records. |
| CREATE | Creates databases and tables. |
| INSERT | Adds new records. |
| UPDATE | Modifies existing records. |
| DELETE | Removes records. |
Important Points to Remember
- SQL is the standard language used to work with relational databases.
- SQL allows users to create, retrieve, update, and delete data efficiently.
- MySQL is one of the most widely used open-source RDBMS software.
- DDL commands define and modify database structures.
- DML commands manipulate records stored in tables.
- DQL is mainly used for retrieving data using the SELECT command.
- SQL keywords are generally case-insensitive, but writing them in uppercase improves readability.
- Every SQL statement should end with a semicolon (;).
- SQL is used in schools, banks, hospitals, e-commerce websites, and many other real-world applications.
CBSE Exam Tips
- Remember the full forms of SQL, DDL, DML, DQL, and RDBMS.
- Learn the purpose of each SQL command category with examples.
- Do not confuse DELETE with DROP. DELETE removes records, while DROP removes the entire database object.
- Practice identifying the correct SQL command for different situations.
- Memorize the commonly used SQL keywords such as CREATE, INSERT, SELECT, UPDATE, DELETE, and DROP.
Summary
SQL (Structured Query Language) is the standard language used to communicate with relational databases. It enables users to create databases, define tables, insert records, retrieve information, update existing data, and delete unwanted records. SQL commands are classified into DDL, DML, and DQL based on their functions. MySQL, one of the most popular open-source RDBMS software, uses SQL to manage data efficiently. A strong understanding of SQL basics forms the foundation for learning advanced database concepts and developing real-world database applications.