Curriculum
Course: Grade XI Informatics Practices
Login
Text lesson

Ch6-SQL-Creating-and-Managing-Tables

School Revise · Class 11 Informatics Practices · Chapter 6

SQL Creating and Managing Tables

Code 065, Class 11. SQL builds and changes the tables of a database. Here we create tables, add rows, and change the table structure.

DDL

defines tables

DML

works with rows

What this chapter is about

DDL commands define a table (CREATE, ALTER, DROP), and DML commands work with its rows (INSERT, UPDATE, DELETE).

1. Creating a table

CREATE TABLE makes a table with columns and their data types, such as INT, VARCHAR and DATE. A column can have a constraint like PRIMARY KEY or NOT NULL.

CREATE TABLE STUDENT ( rollno INT PRIMARY KEY, name VARCHAR(20), marks INT );

2. Adding and changing rows

INSERT INTO adds a row, UPDATE changes values (with WHERE), and DELETE removes rows (with WHERE).

3. Changing the structure

ALTER TABLE adds or changes a column, and DROP TABLE removes the whole table.

Practise with the interactive

Explore the idea by tapping. The interactive opens right here in the lesson.

Coding practice problems, with answers

Type each one into the code lab above, then open the card to see the worked solution and its output.

Problem 1. Create a table.

SOLUTION

CREATE TABLE STUDENT (rollno INT PRIMARY KEY, name VARCHAR(20), marks INT);

OUTPUT

an empty STUDENT table is created
Problem 2. Insert a row.

SOLUTION

INSERT INTO STUDENT VALUES (1, “Ravi”, 82);

OUTPUT

one row is added to STUDENT
Problem 3. Insert another row.

SOLUTION

INSERT INTO STUDENT VALUES (2, “Sana”, 91);

OUTPUT

a second row is added
Problem 4. Show all rows.

SOLUTION

SELECT * FROM STUDENT;

OUTPUT

all rows and columns of STUDENT
Problem 5. Change a mark.

SOLUTION

UPDATE STUDENT SET marks = 95 WHERE rollno = 1;

OUTPUT

marks of roll number 1 becomes 95
Problem 6. Delete a row.

SOLUTION

DELETE FROM STUDENT WHERE rollno = 2;

OUTPUT

the row with roll number 2 is removed
Problem 7. Add a new column.

SOLUTION

ALTER TABLE STUDENT ADD city VARCHAR(20);

OUTPUT

a city column is added to STUDENT
Problem 8. Set a column to not allow empty values.

SOLUTION

CREATE TABLE T (id INT NOT NULL);

OUTPUT

id must always have a value
Problem 9. Make a primary key.

SOLUTION

CREATE TABLE T (id INT PRIMARY KEY, name VARCHAR(10));

OUTPUT

id uniquely identifies each row
Problem 10. Remove the whole table.

SOLUTION

DROP TABLE STUDENT;

OUTPUT

the STUDENT table is deleted

Practice set A, multiple choice

1. Which command creates a table?

CREATE TABLE.

2. Which command adds a row?

INSERT INTO.

3. Which changes the table structure?

ALTER TABLE.

4. Which removes the whole table?

DROP TABLE.

Quick summary

DDL defines tables: CREATE TABLE makes a table with columns, data types (INT, VARCHAR, DATE) and constraints (PRIMARY KEY, NOT NULL); ALTER TABLE changes the structure and DROP TABLE removes it. DML works with rows: INSERT adds, UPDATE changes and DELETE removes, and UPDATE and DELETE use a WHERE clause.

Open the Virtual Lab

These free Class 11 Informatics Practices notes explain SQL DDL and DML, creating tables with data types and constraints, INSERT UPDATE and DELETE, and ALTER and DROP TABLE with worked examples and practice, for CBSE students across India and the Gulf including the UAE, Saudi Arabia, Qatar, Oman, Kuwait and Bahrain.

© 2026 School Revise. All rights reserved. Original content aligned to the CBSE and NCERT Class 11 Informatics Practices syllabus. Unauthorised copying is not permitted.

Layer 1
Login Categories