On this page
Most SQL practice is SELECT queries, so students reach the exam unsure about the commands that build and change tables. Then a question asks for the difference between ALTER and UPDATE, or for a command to add a column, and the answer comes out half right. This post covers the commands that create and modify tables and data, works them on one small table from start to finish, and lists the mistakes examiners see most.
What does the syllabus include?
The CBSE Computer Science curriculum for 2026-27 lists, for Class 12, Data Definition Language and Data Manipulation Language, data types (char(n), varchar(n), int, float, date), constraints (not null, unique, primary key), create, use, show and drop database, create table, describe table, alter table (add and remove an attribute, add and remove a primary key), drop table, insert, delete and update. The Informatics Practices curriculum covers the same commands in Class 11: CREATE DATABASE, CREATE TABLE, DROP, ALTER, INSERT, DELETE and UPDATE.
The textbook treatment is in NCERT Class 12 Computer Science, Chapter 9, Structured Query Language (SQL).
DDL or DML: what is the difference?
DDL (Data Definition Language) defines or changes the structure, the schema: CREATE, ALTER, DROP.
DML (Data Manipulation Language) works on the records: INSERT adds rows, UPDATE changes values, DELETE removes rows.
The 2026-27 CS sample paper asks in question 27(B) to "differentiate between alter and update command". The marking scheme answer: ALTER changes the structure of a table, adding, deleting or modifying columns; UPDATE modifies the data stored in the table. The IP sample paper asks in question 6 which of ALTER, DROP, UPDATE and CREATE is a DML command; the answer is UPDATE.
Worked example: one table, start to finish
A school club keeps a small table. These are sample names and numbers, made up for practice. We ran each step to check the result.
Step 1: create the table.
CREATE TABLE CLUB (
MemberID INT PRIMARY KEY,
MName VARCHAR(20) NOT NULL,
Grade INT,
Fee INT
);Step 2: insert four rows.
INSERT INTO CLUB VALUES (1, 'Asha', 11, 300);
INSERT INTO CLUB VALUES (2, 'Rohan', 12, 300);
INSERT INTO CLUB (MemberID, MName, Grade) VALUES (3, 'Meera', 11);
INSERT INTO CLUB VALUES (4, 'Kabir', 12, 300);The third insert names its columns, so Fee is left NULL. Without a column list, you must give a value for every column in order.
Step 3: add a column (DDL).
ALTER TABLE CLUB ADD Phone VARCHAR(10);Every existing row now has Phone as NULL. The table's degree (number of columns) goes from 4 to 5; its cardinality (number of rows) is still 4.
Step 4: change values (DML).
UPDATE CLUB SET Fee = 350 WHERE Grade = 12;
UPDATE CLUB SET Fee = 300 WHERE Fee IS NULL;Rohan and Kabir now pay 350. Meera's NULL fee becomes 300. Writing WHERE Fee = NULL would change nothing, because NULL is never equal to anything; use IS NULL.
Step 5: remove a row (DML).
DELETE FROM CLUB WHERE MemberID = 4;The table now has three rows: Asha (11, 300), Rohan (12, 350) and Meera (11, 300). SELECT SUM(Fee) FROM CLUB gives 300 + 350 + 300 = 950.
Step 6: remove a column, then the table (DDL).
ALTER TABLE CLUB DROP Phone;
DROP TABLE CLUB;NCERT writes the column form as ALTER TABLE table_name DROP attribute, while CS sample paper question 19 uses ALTER TABLE Student DROP COLUMN Age. Both are correct: the MySQL manual says the word COLUMN is optional here.
DELETE, DROP or ALTER ... DROP?
These three get mixed up in answers:
DELETE FROM CLUB WHERE ... removes rows. The table and its structure stay.
ALTER TABLE CLUB DROP Phone removes one column from every row.
DROP TABLE CLUB removes the table itself, structure and data. NCERT warns that DROP cannot be undone.
IP sample paper question 37(A) asks for all of these in one go: insert a book, update a price, delete an author's books, add a Publisher column and drop the table. It is a good single-question test of this whole post.
What mistakes cost marks?
Leaving out WHERE. NCERT cautions that UPDATE without WHERE changes every row, and DELETE without WHERE removes every row.
Quotes on numbers, none on text. Text and dates need quotes ('Asha', '2025-01-01'); numbers do not.
Inserting a duplicate primary key. The insert fails. A primary key must be unique and not null.
Inserting a child row first. NCERT notes that the referenced table must already have the matching record before you insert a row with a foreign key.
Using MODIFY to rename. MODIFY changes a column's data type or constraint, not its name.
For SELECT, GROUP BY and joins, see our SQL basics for CBSE. To run these commands from a program, see connecting Python to MySQL.
A practice routine
Build the CLUB table above in MySQL and run each step, checking with SELECT * after each.
Write the result table on paper before every SELECT, then compare.
Redo IP question 37(A) and CS question 27 from the sample papers without notes.
If keys and constraints still feel abstract, the Fermi Concept Library covers every concept in physics, chemistry, biology, mathematics and computing, including the computing ideas behind relational tables.
Open MySQL tonight and type the six steps above, one at a time.



