What is SQL?

SQL (Structured Query Language) is a special language that lets you talk to a database. Think of a database like a huge digital filing cabinet, and SQL is the set of commands you use to open a drawer, look for a file, add a new one, or throw away an old one.

Why learn SQL in Class 12 CBSE?

CBSE’s Computer Science syllabus expects you to write simple SQL statements, understand how data is stored, and be able to retrieve it. Knowing SQL not only helps you ace the board exam, it also prepares you for real‑world jobs where data handling is everyday work.

💡 In Simple Words: SQL is the way you ask a computer’s data “show me all the students who scored above 80”. It’s like asking a librarian to fetch books that match a description.

Basic SQL Commands You Must Know

SQL commands are grouped into categories. The most common for Class 12 are DML (Data Manipulation Language) commands – they let you change the data inside tables.

  • SELECT – fetches data from a table.
  • INSERT – adds new rows (records) to a table.
  • UPDATE – changes existing data.
  • DELETE – removes rows.

SELECT – retrieving data

The SELECT statement is like a question you ask the database. The basic shape is:

SELECT column1, column2 FROM table_name WHERE condition;

Example: Suppose you have a table students with columns name, grade, and score. To list every student who scored more than 80, you write:

SELECT name, score FROM students WHERE score > 80;

INSERT – adding data

INSERT puts a new row into a table. The pattern looks like:

INSERT INTO table_name (col1, col2, col3) VALUES (val1, val2, val3);

Example:

INSERT INTO students (name, grade, score) VALUES ('Riya', '12th', 92);

UPDATE – modifying data

UPDATE changes existing rows that meet a condition. Syntax:

UPDATE table_name SET column1 = new_value WHERE condition;

Example – give every student in grade 11 a bonus of 5 points:

UPDATE students SET score = score + 5 WHERE grade = '11th';

DELETE – removing data

DELETE erases rows. Use it carefully! The form is:

DELETE FROM table_name WHERE condition;

Example – delete records of students who have left the school:

DELETE FROM students WHERE grade = '10th' AND score IS NULL;

SQL Query Execution Process

graph TD A[Start] --> B[Connect to Database] B --> C[Write SQL Statement] C --> D[Execute Statement] D --> E[Get Result Set] E --> F[Display Results] F --> G[End]

Quick Comparison of DML Commands

CommandPurposeTypical Syntax
SELECTRead dataSELECT cols FROM table WHERE …;
INSERTAdd new rowsINSERT INTO table (cols) VALUES (vals);
UPDATEChange existing rowsUPDATE table SET col=val WHERE …;
DELETERemove rowsDELETE FROM table WHERE …;

Tips for CBSE Exams

  • Remember the order of clauses in SELECT: SELECT → FROM → WHERE → ORDER BY → LIMIT. The exam often asks you to write the correct sequence.
  • Use uppercase for keywords (SELECT, FROM) – it makes your answer neat and easier to read.
  • When a question says “display all columns”, write SELECT *. The asterisk means “everything”.
  • Practice writing queries on paper without a computer; the board marks syntax exactly as you write.

📝 Likely Exam Questions

  1. Write an SQL query to list the names of all students who scored between 70 and 90.
    SELECT name FROM students WHERE score BETWEEN 70 AND 90;
  2. Insert a new record for a student named “Amit” in class 12 with a score of 85.
    INSERT INTO students (name, grade, score) VALUES ('Amit', '12th', 85);
  3. Update the score of every student in class 11 by adding 3 marks.
    UPDATE students SET score = score + 3 WHERE grade = '11th';
  4. Delete records of students whose score is null.
    DELETE FROM students WHERE score IS NULL;
  5. Explain in a few lines what the SELECT statement does.
    SELECT tells the database which columns to retrieve from which table, optionally filtering rows with a WHERE clause.
#CBSE#Class 12#Computer Science#SQL#Database