Kerala Plus Two Computer Science Previous Questions Chapter 9 Structured Query Language

Solutions for Class 12 Computer Science: Chapter 09 Structured Query Language

Access comprehensive textbook solutions for Chapter 09 Structured Query Language using the official curriculum guides for Class 12 Computer Science. Designed to align with the 2026-27 Kerala Board standards, these detailed answers help students reinforce core academic concepts.

Practice Class 12 Computer Science Solutions: Chapter 09 Structured Query Language

Access the complete solution PDF for Class 12 Computer Science below. Regular practice with these targeted textbook answers builds familiarity with standard question patterns and helps secure higher marks in final school evaluations.

Previous Questions and Answers

Question 1: Which keyword is used in a SELECT statement to avoid duplicate rows? (March 2008)

Answer:

DISTINCT

Exam Tips:

a) The keyword is written right after SELECT, for example SELECT DISTINCT city FROM student;

 

Question 2: The columns used in a table are called ______ (March 2008)

Answer:

Attributes

Exam Tips:

a) Columns are attributes (fields) and rows are tuples (records); learn both pairs of terms together.

 

Question 3: Manju wants to create a table for a new inventory application. The table contains the details of products in a shop: item code, description, stock quantity and reorder level. Write the SQL command to create this table with the necessary constraints. (March 2008)
a) Item code should not be empty for any row and it must be the primary key.
b) Description should have some value.
c) The reorder level should be at least 10.

Answer:

CREATE TABLE inventory (
  itemcode INT NOT NULL PRIMARY KEY,
  description CHAR(30) NOT NULL,
  stock_qty INT,
  rol INT CHECK (rol >= 10)
);

Exam Tips:

a) Primary key already implies NOT NULL, but writing NOT NULL PRIMARY KEY as the question asks is safe.
b) Use a CHECK constraint for a condition such as "at least 10"; end the statement with a semicolon.

 

Question 4: Name any two aggregate functions. (March 2008)

Answer:

SUM() and AVG()

Exam Tips:

a) The five aggregate functions are SUM, AVG, MIN, MAX and COUNT; name any two with brackets.

 

Question 5: A village hospital has maintained a database for patients with the fields IPNO (primary key, varchar(10)), PatientName varchar(20), Age number(3), Roomno number(3). Write SQL queries to do the following. (February 2008)
a) Modify the table by adding the field Doctorname (not null).
b) Update the Doctorname field with the value 'LINDA' for the record with IPNO=30.
c) Display all patients grouped by doctor name.
d) Display all patients in the age group 20 to 30 years.
e) Display the details of all patients whose name starts with 'An'.

Answer:

a) ALTER TABLE patient ADD (Doctorname CHAR(20) NOT NULL);
b) UPDATE patient SET Doctorname = 'LINDA' WHERE IPNO = 30;
c) SELECT * FROM patient GROUP BY Doctorname;
d) SELECT * FROM patient WHERE age BETWEEN 20 AND 30;
e) SELECT * FROM patient WHERE PatientName LIKE 'An%';

Exam Tips:

a) Use ALTER TABLE ... ADD to add a column and UPDATE ... SET ... WHERE to change a particular row.
b) BETWEEN includes both end values; % in LIKE stands for any number of characters.
c) Write each part separately with its letter so every query gets its mark.

 

Question 6: Duplication of data is called ______ (February 2008)

Answer:

Data redundancy

Exam Tips:

a) Redundancy wastes storage and can lead to inconsistency; a DBMS helps to control it.

 

Question 7: Explain aggregate functions. OR Write any four aggregate functions in SQL and their uses. (February 2008)

Answer:

Aggregate functions work on a set of values in a column and return a single value.
1) SUM() - finds the total of the values in the given column.
2) AVG() - finds the average of the values in the given column.
3) MIN() - finds the smallest value in the given column.
4) MAX() - finds the largest value in the given column.
5) COUNT() - finds the number of values in the given column.

Exam Tips:

a) Write the function name along with its use; if four are asked, four are enough.
b) Add a small example such as SELECT MAX(mark) FROM student; to make the answer clear.

 

Question 8: Which command is used to remove a table from a database? (February 2008)

Answer:

DROP TABLE <table name>;

Exam Tips:

a) DROP TABLE removes the structure and the data, whereas DELETE FROM removes only the rows.

 

Question 9: A view can be used just like a table. Then what is the purpose of creating a view? (February 2008)

Answer:

A view is a virtual table; it does not really exist as stored data. A view can be created from a table, so users can see only the selected part of the data and not the entire table. Thus a view gives higher security.

Exam Tips:

a) Mention the two key words: virtual table and security.
b) Give the syntax CREATE VIEW viewname AS SELECT ... if space permits.

 

Question 10: Ceena wants to delete the records of all Commerce students having marks less than 35 from the table named Student. Name, RegNo, Subject and Marks are the fields of the table. Write the SQL command for this. (March 2009)

Answer:

DELETE FROM Student WHERE Subject = 'Commerce' AND Marks < 35;

Exam Tips:

a) Combine the two conditions with AND, and put text values in quotes.
b) Never forget the WHERE clause, otherwise all rows are deleted.

 

Question 11: Which keyword can be used with the SELECT command to avoid duplication of rows in the selection? (March 2009)

Answer:

DISTINCT

Exam Tips:

a) The same question is repeated often in this chapter; DISTINCT is the one-word answer.

 

Question 12: A company wants to create a table to store the stock details. Write SQL commands for the following. (June 2009)
1) Create a table named stock with the fields item code, name, qty and unit price.
2) Insert 2 records into the table.
3) Display the items in ascending order of name.
4) List all the items where qty is less than 10.
5) List all items with a price greater than 100.
The name field is of char type and the others are numeric.

Answer:

1) CREATE TABLE stock (itemcode DECIMAL(4), name CHAR(25), qty DECIMAL(4), price DECIMAL(8,2));
2) INSERT INTO stock VALUES (101, 'Pears', 1000, 48);
INSERT INTO stock VALUES (102, 'Apple', 5, 120);
3) SELECT name FROM stock ORDER BY name;
4) SELECT name FROM stock WHERE qty < 10;
5) SELECT name FROM stock WHERE price > 100;

Exam Tips:

a) Use character type for the name and numeric types (DECIMAL or INT) for the others, exactly as the question says.
b) ORDER BY sorts in ascending order by default.
c) Check the direction of every comparison sign (< or >) against the question.

 

Question 13: What are the features of Data Manipulation Language which make it attractive? (June 2009)

Answer:

DML works on the instance (the data) of the database. It provides commands for inserting rows into a table and deleting rows from a table. It also allows the contents of the tables to be modified and the information in the database to be retrieved. The DML commands are INSERT, UPDATE, DELETE and SELECT.

Exam Tips:

a) Cover the four operations: insert, delete, modify and retrieve.
b) List the four command names to complete the answer.

 

Question 14: Prabha created a table in SQL with 10 records. Which DML command is used to change the values in a column of specified rows? Write the format also. (June 2009)

Answer:

UPDATE is the DML command used to change the values in a column of specified rows. The SET keyword gives the new value and the WHERE clause selects the rows to be changed.
Syntax: UPDATE <table name> SET <column name> = value WHERE <condition>;
Example: UPDATE Student SET age = 17 WHERE rollno = 1;

Exam Tips:

a) Write both the syntax and a small example.
b) Without WHERE, every row of the table is updated.

 

Question 15: Write a query on the CUSTOMER table whose output will exclude all customers with a RATING <= 100, unless they are located in Kochi. (February 2009)

Answer:

SELECT * FROM CUSTOMER WHERE RATING > 100 OR Place = 'Kochi';

Exam Tips:

a) "Exclude RATING <= 100 unless in Kochi" means keep those with RATING above 100 and also those from Kochi, so the connecting word is OR.
b) Test your query on one customer from each case before finalising.

 

Question 16: A table BANK consists of the fields Acc No, Customer Name, age, Type of deposit (Savings, Current, Fixed) and Deposited Amount. Write SQL statements to: (March 2010)
a) Display Acc No and Customer Name of those whose age is greater than 60.
b) Display Acc No and Customer Name of those having a Savings account.
c) Display the Customer Names starting with the letter A.
d) Display the Acc No and Customer Name of those who deposited above 1 lakh rupees as Fixed Deposit.
e) Include a new field Address.

Answer:

a) SELECT accno, name FROM Bank WHERE age > 60;
b) SELECT accno, name FROM Bank WHERE type_of_deposit = 'Savings';
c) SELECT name FROM Bank WHERE name LIKE 'A%';
d) SELECT accno, name FROM Bank WHERE type_of_deposit = 'Fixed' AND amount > 100000;
e) ALTER TABLE Bank ADD (Address CHAR(30));

Exam Tips:

a) Match the comparison exactly: "greater than 60" is > 60, not >= 60.
b) 1 lakh is 100000; write it without commas.
c) Use ALTER TABLE ... ADD for a new column.

 

Question 17: Find the odd one out. (March 2010)
a) Oracle
b) SQL Server
c) DDL
d) MySQL

Answer:

c) DDL. Oracle, SQL Server and MySQL are database management systems, whereas DDL is a part of the SQL language.

Exam Tips:

a) Give the reason along with the odd one out.

 

Question 18: Can you find any alternate keys in the following table? Justify your answer. (March 2010)

Reg_noRoll_noYearName
112001Ramya
222001Resmi
332001Sheeba
412002Sona
522002Soumya

Answer:

A candidate key that is not chosen as the primary key is called an alternate key. Here the candidate keys are Reg_no, Roll_no + Year and Roll_no + Name. If Reg_no is set as the primary key, the other candidate keys (Roll_no + Year and Roll_no + Name) are the alternate keys. So yes, alternate keys exist.

Exam Tips:

a) Roll_no alone repeats (1 and 2 appear twice), so it needs another column to form a key.
b) Define candidate key and alternate key first, then name them.

 

Question 19: A table Student consists of the fields Rollno, Name, Batch and Mark. Write SQL statements to: (June 2010)
a) Display Rollno and Name of students whose mark is less than 90 and greater than 70.
b) Display Rollno and Name of all students in the Science batch whose mark is more than 90.
c) Display the Names of all students in the Commerce and Humanities batches.
d) Display the Rollno and Name in ascending order of batch and descending order of mark.
e) Display the number of students in each batch.

Answer:

a) SELECT Rollno, Name FROM Student WHERE Mark < 90 AND Mark > 70;
b) SELECT Rollno, Name FROM Student WHERE Batch = 'Science' AND Mark > 90;
c) SELECT Name FROM Student WHERE Batch = 'Commerce' OR Batch = 'Humanities';
d) SELECT Rollno, Name FROM Student ORDER BY Batch, Mark DESC;
e) SELECT Batch, COUNT(Mark) FROM Student GROUP BY Batch;

Exam Tips:

a) For "Commerce and Humanities" students use OR (or IN), because one student belongs to only one batch.
b) In ORDER BY, ascending is the default; add DESC only for the column that must be descending.
c) Use GROUP BY with COUNT to get a count for each group.

 

Question 20: Write the essential clause required for each of the following SQL commands. (June 2010)
a) Insert Into
b) Select
c) Update

Answer:

a) INSERT INTO - VALUES
b) SELECT - FROM
c) UPDATE - SET

Exam Tips:

a) Remember the pairs INSERT INTO-VALUES, SELECT-FROM and UPDATE-SET; they appear again in the assess questions.

 

Question 21: Write the syntax of the CREATE TABLE command. (June 2010)

Answer:

CREATE TABLE <table name> (
<column name> <data type> [(size)] [<column constraints>],
<column name> <data type> [(size)] [<column constraints>],
...);

Exam Tips:

a) Separate the column definitions with commas and end the statement with a semicolon.
b) Add a one-line example, such as CREATE TABLE student (rollno INT PRIMARY KEY, name CHAR(20));

 

Question 22: Consider the following table Student: (March 2011)

NameSexCoursePer
SandeepMScience85
MartinMCommerce70
ShijiFCommerce75

a) Write a query to display the names and percentage of all male students in the Science branch.
b) Write an UPDATE command to set the Course attribute to 'Humanities' for the student whose NAME is 'Shiji'.

Answer:

a) SELECT Name, Per FROM Student WHERE Sex = 'M' AND Course = 'Science';
b) UPDATE Student SET Course = 'Humanities' WHERE Name = 'Shiji';

Exam Tips:

a) Text values such as 'M' and 'Science' must be in quotes.
b) Use = (not a hyphen) in the WHERE condition.

 

Question 23: The SQL Data Manipulation Language (DML) includes a query language based on relational algebra. (March 2011)
a) Give any four commands used in DML.
b) Write an SQL statement to INSERT the values (101, "Anoop", "Science", 75) into the fields (adm_no, name, course, percent) of the table STUD.

Answer:

a) INSERT, DELETE, SELECT and UPDATE
b) INSERT INTO STUD VALUES (101, 'Anoop', 'Science', 75);

Exam Tips:

a) Values are given in the same order as the columns of the table; text values go inside quotes.

 

Question 24: Tina wants to create a table named mark with the fields name, regno, mark1, mark2 and total. Write the SQL command to create the table with regno as the primary key. (March 2012)

Answer:

CREATE TABLE mark (
  name CHAR(20),
  regno DECIMAL(4) NOT NULL PRIMARY KEY,
  mark1 DECIMAL(3),
  mark2 DECIMAL(3),
  total DECIMAL(3)
);

Exam Tips:

a) Attach the PRIMARY KEY constraint to the regno column itself.
b) Give a suitable data type and size for every column.

 

Question 25: While naming a table in SQL, Reena typed 'Select' as the table name. Is there any mistake? Give the reason. (March 2012)

Answer:

Yes, there is a mistake. Keywords (reserved words) or commands cannot be used to name a table. SELECT is a keyword of SQL.

Exam Tips:

a) State "Yes" first and then the reason.
b) Reserved words such as SELECT, TABLE and ORDER cannot be used as names of tables or columns.

 

Question 26: Give the correct syntax of the queries in SQL for the following: (March 2016)
a) Renaming a table
b) Deleting rows from a table
c) Changing the definition of a column
d) Removing columns from a table
e) Adding a new column

Answer:

a) ALTER TABLE <table name> RENAME TO <new table name>;
b) DELETE FROM <table name> [WHERE <condition>];
c) ALTER TABLE <table name> MODIFY <column name> <data type> [(size)] [<constraint>];
d) ALTER TABLE <table name> DROP <column name>;
e) ALTER TABLE <table name> ADD <column name> <data type> [(size)] [<constraint>];

Exam Tips:

a) Four of the five commands use ALTER TABLE: RENAME TO, MODIFY, DROP and ADD.
b) Square brackets show optional parts and angle brackets show the names to be supplied.

 

Question 27: Give the output obtained with the pattern match '___' (three underscores) on the string 'board'. (March 2016)

Answer:

The pattern '___' matches any string of exactly 3 characters. The string 'board' has 5 characters, so it will not be selected (no output).

Exam Tips:

a) In LIKE, each underscore stands for exactly one character, while % stands for any number of characters.
b) Count the characters in the string and compare with the number of underscores.

 

Question 28: What happens when we use the DELETE FROM command without a WHERE clause? (May 2016)

Answer:

All the tuples (rows/records) are deleted from the table; the table structure remains.

Exam Tips:

a) Only the rows are deleted; the table itself still exists (unlike DROP TABLE).

 

Question 29: If a table named mark has the fields regNo, subCode and marks, write SQL statements for the following: (May 2016)
a) List the subject codes eliminating duplicates.
b) List the marks obtained by students with subject codes 3001 and 3002.
c) Arrange the table based on marks for each subject.
d) List all the students who have obtained marks above 90 for the subject codes 3001 and 3002.
e) List the contents of the table in descending order of marks.

Answer:

a) SELECT DISTINCT subCode FROM mark;
b) SELECT marks FROM mark WHERE subCode = 3001 OR subCode = 3002;
c) SELECT * FROM mark ORDER BY subCode, marks;
d) SELECT * FROM mark WHERE subCode IN (3001, 3002) AND marks > 90;
e) SELECT * FROM mark ORDER BY marks DESC;

Exam Tips:

a) IN (3001, 3002) is a short way of writing two OR conditions.
b) Use DISTINCT to eliminate duplicates and ORDER BY ... DESC for descending order.

 

Question 30: Distinguish between DDL and DML and give examples for each type. (May 2016)

Answer:

Data Definition Language (DDL) is used to define the structure of a table and the definitions of the database schema. The result of compiling DDL statements is a set of tables stored in a special file called the data dictionary. DDL commands are CREATE TABLE, ALTER TABLE and DROP TABLE.
Data Manipulation Language (DML) is used to add, retrieve, modify and delete the records in a database. It enables users to access or manipulate the data in the database and also provides interfaces with programming languages. DML commands are SELECT, INSERT, UPDATE and DELETE.

Exam Tips:

a) Present the answer as two short points, one for DDL and one for DML, each with examples.
b) Remember: DDL deals with structure, DML deals with data.

 

Question 31: Null values in tables are specified as "null". State whether true or false. (May 2016)

Answer:

False. A null value is written as NULL without quotes; if "null" is written inside quotes it is treated as an ordinary text string and not as a null value.

Exam Tips:

a) Give a one-line reason with a true/false answer.
b) NULL means an unknown or empty value, and it is not the same as zero or a blank space.

 

Question 32: Which command is used to delete a table? (May 2017)
a) delete from
b) drop table
c) delete table
d) drop view

Answer:

b) drop table

Exam Tips:

a) DROP TABLE deletes the whole table, structure and data.

 

Question 33: Differentiate between the CHAR and VARCHAR data types in SQL. (May 2017)

Answer:

CHAR is used to store a fixed number of characters; it is declared as char(size).
VARCHAR is used to store characters but it uses only as much memory as the data needs; it is declared as varchar(size).

Exam Tips:

a) Use the keywords "fixed length" for CHAR and "variable length" for VARCHAR.

 

Question 34: Name the most appropriate SQL data type required to store the following data: (May 2017)
a) Name of a student (maximum 70 characters)
b) Date of birth of a student
c) Percentage of marks obtained (correct to 2 decimal places)

Answer:

a) VARCHAR(70)
b) DATE
c) DECIMAL (for example DECIMAL(5,2))

Exam Tips:

a) A name has varying length, so VARCHAR is better than CHAR.
b) For values with decimal places choose DECIMAL(size, d), where d is the number of digits after the decimal point.

 

Question 35: As part of your school project you are asked to create a relation Student containing the details of 10 students with the fields Roll No, Name, Date of Birth and Score in IT. The constraints required are: Roll No is the primary key, name cannot be empty and the score in IT should be less than 60. Based on this table Student, answer the following queries in relational algebra. (May 2017)
a) Display the details of students whose score is greater than 50.
b) Display the names of students whose score lies between 45 and 60 (both inclusive).

Answer:

The relation Student:

Roll NoNameDate Of BirthIT Score
1Raju15.04.200355
2Leo25.03.200343
3Geo15.05.200344
4Alvis15.02.200356
5Adeline15.10.200254
6Ann25.01.200334
7Andrea11.04.200357
8Jose17.04.200334
9Christy13.03.200343
10George22.04.200340

a) \(\sigma_{IT\_Score > 50}(Student)\)

Roll NoNameDate Of BirthIT Score
1Raju15.04.200355
4Alvis15.02.200356
5Adeline15.10.200254
7Andrea11.04.200357

b) \(\pi_{Name}(\sigma_{IT\_Score \geq 45 \text{ and } IT\_Score \leq 60}(Student))\)

Name
Raju
Alvis
Adeline
Andrea

Exam Tips:

a) SELECT (sigma) chooses rows by a condition and PROJECT (pi) chooses columns; combine them with project outside and select inside.
b) Show the result table after each relational algebra expression.
c) The score constraint is "less than 60", so no score in the table can be 60 or more.

 

Practice Questions and Answers

Question 36: The structure of a table is given to store the details of marks scored by students in an examination.

DataTypeDescription
Register numberNumericA unique and essential data to identify a student
NameStringA maximum of 30 characters
CourseStringIt can be Science, Commerce or Humanities
Marks of six subjectsNumeric eachSix separate columns are required

Write SQL statements for the creation of the table and the following requirements:
a) Insert data into the fields (at least 10 records).
b) Display the details of all students.
c) List the details of Science group students.
d) Count the number of students in each course.
e) Add a new column named Total to store the total marks.
f) Fill the column Total with the sum of the six marks of each student.
g) Display the highest total in each group.
h) Find the highest, lowest and average score in Subject 6 in the Commerce group.
i) Display the names in alphabetical order in each course.
j) Display the name of the student with the highest total.

Answer:

Creating the table:
CREATE TABLE student1 (
  RegNo INT PRIMARY KEY,
  name VARCHAR(30) NOT NULL,
  course VARCHAR(15),
  mark1 INT, mark2 INT, mark3 INT,
  mark4 INT, mark5 INT, mark6 INT
);
a) Inserting records (sample records shown; insert at least 10 in the same way):
INSERT INTO student1 VALUES (1, 'Jose', 'Science', 70, 60, 70, 80, 90, 70);
INSERT INTO student1 VALUES (2, 'Alvis', 'Commerce', 72, 68, 70, 90, 70, 70);
INSERT INTO student1 VALUES (3, 'Andrea', 'Humanities', 72, 68, 80, 90, 70, 80);
b) SELECT * FROM student1;
The output lists all the records: (1, Jose, Science, 70, 60, 70, 80, 90, 70), (2, Alvis, Commerce, 72, 68, 70, 90, 70, 70) and (3, Andrea, Humanities, 72, 68, 80, 90, 70, 80).
c) SELECT * FROM student1 WHERE course = 'Science';
d) SELECT course, COUNT(*) FROM student1 GROUP BY course;
e) ALTER TABLE student1 ADD (total INT);
f) UPDATE student1 SET total = mark1 + mark2 + mark3 + mark4 + mark5 + mark6;
g) SELECT course, MAX(total) FROM student1 GROUP BY course;
h) SELECT MAX(mark6), MIN(mark6), AVG(mark6) FROM student1 WHERE course = 'Commerce';
i) SELECT course, name FROM student1 ORDER BY course, name;
j) SELECT name FROM student1 WHERE total = (SELECT MAX(total) FROM student1);

Exam Tips:

a) Create the table first with a primary key on RegNo, then insert at least 10 records as the question asks.
b) Use GROUP BY for "in each course" and a subquery with MAX(total) to find the topper.
c) Do not forget the WHERE clause for a particular group such as Commerce.

 

Question 37: The structure of a table is given to store the details of items in a computer shop.

DataTypeDescription
Item numberNumericA unique and essential data to identify an item
Item nameStringA maximum of 30 characters
Date of purchaseDateDuplication is allowed
Unit priceFractionalPrice of a single item
QuantityNumericNumber of items
ManufacturerStringName of the supplier (can duplicate)

Write SQL statements for the creation of the table and the following requirements:
a) Insert data into the fields (at least 10 records).
b) Display the details of all items in the table.
c) Display the names of items and the total price of each.
d) List the items manufactured by a company (specify the name) available in the table.
e) Find the number of items from each manufacturer.
f) Display the details of items with the highest price.
g) List the names of items whose price is more than the average price of all the items.
h) Display the names of items purchased after 1-1-2015.
i) Get the details of items manufactured by two or three companies (specify the names) available in the table.
j) Display the details of items from a company (specify the name) with a stock of more than 20 pieces.

Answer:

CREATE TABLE shop (
  ItemNo INT PRIMARY KEY,
  name CHAR(30) NOT NULL,
  DOP DATE,
  UnitPrice FLOAT(8,2),
  Qty INT,
  mfrer CHAR(30)
);
a) INSERT INTO shop VALUES (1, 'Keyboard', '2014-08-21', 300.00, 100, 'Tech Com');
INSERT INTO shop VALUES (2, 'Mouse', '2014-08-21', 300.00, 100, 'Tech Com');
INSERT INTO shop VALUES (3, 'Speaker', '2015-08-21', 550.00, 100, 'I Ball');
INSERT INTO shop VALUES (4, 'CPU', '2015-07-21', 3500.00, 100, 'AMD');
INSERT INTO shop VALUES (5, 'RAM', '2015-08-11', 1300.00, 100, 'Hynix');
(sample records; insert at least 10 in the same way)
b) SELECT * FROM shop;
c) SELECT name, UnitPrice * Qty FROM shop;
d) SELECT name FROM shop WHERE mfrer = 'Tech Com';
e) SELECT mfrer, COUNT(*) FROM shop GROUP BY mfrer;
f) SELECT * FROM shop WHERE UnitPrice = (SELECT MAX(UnitPrice) FROM shop);
g) SELECT name FROM shop WHERE UnitPrice > (SELECT AVG(UnitPrice) FROM shop);
h) SELECT name FROM shop WHERE DOP > '2015-01-01';
i) SELECT * FROM shop WHERE mfrer IN ('Tech Com', 'I Ball', 'AMD');
j) SELECT * FROM shop WHERE mfrer = 'I Ball' AND Qty > 20;

Exam Tips:

a) The total price of an item is UnitPrice * Qty; it can be shown in the SELECT list as an expression.
b) For "more than the average", use a subquery with AVG; the same pattern with MAX gives the highest price.
c) Write dates in the form 'YYYY-MM-DD' inside quotes.

 

Question 38: The structure of a table is given to store the details of higher secondary school teachers.

DataTypeDescription
Teacher IDNumericA unique and essential data to identify a teacher
NameStringA maximum of 30 characters
GenderCharacterMale or Female
Date of joiningDateDuplication is allowed
DepartmentStringScience, Commerce, Humanities or Language
Basic payNumericBasic salary of a teacher

Write SQL statements for the creation of the table and the following requirements:
a) Insert data into the fields (at least 10 records).
b) Display the details of all female teachers in the table.
c) List the details of male teachers in the Science department.
d) Display the names and basic pay of teachers in the Language department whose basic pay is Rs. 21000/- or more.
e) Display the names and 71% of the basic pay of the teachers.
f) Find the number of teachers in each department.
g) Display the details of teachers whose basic pay is less than the average basic pay.
h) List the male teachers who joined before 1-1-2010.
i) Increment the basic pay of all teachers by Rs. 1000/-.
j) Delete the details of teachers from the Language department.

Answer:

CREATE TABLE hsst (
  TeacherId INT PRIMARY KEY,
  name VARCHAR(30) NOT NULL,
  gender CHAR,
  DOJ DATE,
  Dept VARCHAR(15),
  BP FLOAT(8,2)
);
a) INSERT INTO hsst VALUES (1, 'Jose', 'M', '2002-01-01', 'Science', 25660);
INSERT INTO hsst VALUES (2, 'Christy', 'F', '2012-01-01', 'Commerce', 20740);
INSERT INTO hsst VALUES (3, 'Geejo George', 'M', '2007-01-01', 'Humanities', 22360);
(sample records; insert at least 10 in the same way)
b) SELECT * FROM hsst WHERE gender = 'F';
c) SELECT * FROM hsst WHERE gender = 'M' AND Dept = 'Science';
d) SELECT name, BP FROM hsst WHERE Dept = 'Language' AND BP >= 21000;
e) SELECT name, BP * .71 FROM hsst;
f) SELECT Dept, COUNT(*) FROM hsst GROUP BY Dept;
g) SELECT * FROM hsst WHERE BP < (SELECT AVG(BP) FROM hsst);
h) SELECT * FROM hsst WHERE gender = 'M' AND DOJ < '2010-01-01';
i) UPDATE hsst SET BP = BP + 1000;
j) DELETE FROM hsst WHERE Dept = 'Language';

Exam Tips:

a) "Rs. 21000 or more" needs >=, not >.
b) "Increment all teachers" needs UPDATE without a WHERE clause; "from the Language department" in part j needs the WHERE clause.
c) Percentage of pay is BP * .71 (71/100 = .71).

 

Question 39: The structure of a table is given to store the details of customers in a bank.

DataTypeDescription
Account numberNumericA unique and essential data to identify a customer
NameStringA maximum of 30 characters
GenderCharacterMale or Female
Date of joiningDateDuplication is allowed
Type of accountStringSB or Current
Balance amountNumericCan be a fractional number

Write SQL statements for the creation of the table and the following requirements:
a) Insert data into the fields (at least 10 records).
b) Display the details of customers having an SB account.
c) Display the names of customers with a balance amount greater than Rs. 5000/-.
d) Display the details of female customers with a balance amount greater than Rs. 10000/-.
e) Count the number of male and female customers.
f) Display the names of customers with the highest balance amount.
g) Display the names of customers whose names end with 'kumar'.
h) Update the balance amount of a particular customer with a deposit amount of Rs. 2000/-.
i) Display the details of customers with a tax deduction of 2% of the balance amount for those who have Rs. 2,00,000/- in their account.
j) Delete the details of customers with a current account.

Answer:

CREATE TABLE customer (
  AccNo INT PRIMARY KEY,
  name VARCHAR(30),
  gender CHAR,
  DOJ DATE,
  TypeOfAcc CHAR(8),
  Balance DOUBLE(10,2)
);
a) INSERT INTO customer VALUES (1001, 'Adeline', 'F', '2008-11-26', 'SB', 50000.00);
INSERT INTO customer VALUES (1002, 'Alvis', 'M', '2007-05-19', 'Current', 500000.00);
INSERT INTO customer VALUES (1003, 'Andrea', 'F', '2012-07-29', 'SB', 450000.00);
(sample records; insert at least 10 in the same way)
b) SELECT * FROM customer WHERE TypeOfAcc = 'SB';
c) SELECT name FROM customer WHERE Balance > 5000;
d) SELECT * FROM customer WHERE gender = 'F' AND Balance > 10000;
e) SELECT gender, COUNT(*) FROM customer GROUP BY gender;
f) SELECT name FROM customer WHERE Balance = (SELECT MAX(Balance) FROM customer);
g) SELECT name FROM customer WHERE name LIKE '%kumar';
h) UPDATE customer SET Balance = Balance + 2000 WHERE AccNo = 1001;
i) SELECT AccNo, name, Balance * .02 FROM customer WHERE Balance >= 200000;
j) DELETE FROM customer WHERE TypeOfAcc = 'Current';

Exam Tips:

a) '%kumar' matches names that end with kumar; the % goes before the text.
b) A 2% deduction is Balance * .02.
c) Use a WHERE clause with the account number in UPDATE so that only one customer is changed.

 

Assess Questions and Answers

Question 40: The command to remove rows from a table CUSTOMER is:
a) Remove From Customer
b) Drop Table Customer
c) Delete From Customer
d) Update Customer

Answer:

c) Delete From Customer

Exam Tips:

a) DELETE FROM removes rows; DROP TABLE removes the whole table.

 

Question 41: If values for some columns are unknown, how is a row inserted?

Answer:

In this case the column list must be included after the table name, and values are given only for those columns.
Example: INSERT INTO <table name> (column1, column2, ...) VALUES (value1, value2, ...);

Exam Tips:

a) The columns left out receive NULL (or their default value).
b) Write the syntax with a small example.

 

Question 42: Distinguish between the CHAR and VARCHAR data types of SQL.

Answer:

CHAR stores a fixed number of characters and is declared as char(size).
VARCHAR stores characters using only as much memory as needed and is declared as varchar(size).

Exam Tips:

a) Write one point each for fixed length and variable length.

 

Question 43: What is the difference between the PRIMARY KEY and UNIQUE constraints?

Answer:

UNIQUE ensures that no two rows have the same value in a column.
PRIMARY KEY is similar to UNIQUE, but it can be used only once in a table (one primary key per table) and it does not allow null values.

Exam Tips:

a) Mention "only one per table" for PRIMARY KEY, while a table can have several UNIQUE columns.

 

Question 44: What do you mean by a NULL value in SQL?

Answer:

NULL is a keyword in SQL that represents an empty (unknown or missing) value.

Exam Tips:

a) NULL is not zero and not a blank space.

 

Question 45: Which of the following is the correct order of clauses for the SELECT statement?
a) Select, From, Where, Order By
b) Select, From, Order By, Where
c) Select, Where, From, Order By
d) Select, Where, Order By, From

Answer:

a) Select, From, Where, Order By

Exam Tips:

a) Remember the order SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY.

 

Question 46: The SQL operator ______ is used with pattern matching.

Answer:

LIKE

Exam Tips:

a) LIKE uses % for any number of characters and _ for exactly one character.

 

Question 47: Read the following strings:
i) 'Sree Kumar'
ii) 'Kumaran'
iii) 'Kumar Shanu'
iv) 'Sreekumar'
Choose the correct option that matches the pattern '%Kumar' when used with the LIKE operator in a SELECT statement.
a) Strings (i) and (ii) only
b) Strings (i), (iii) and (iv) only
c) Strings (i) and (iii) only
d) All the strings

Answer:

The pattern '%Kumar' matches strings that end with "Kumar", that is, strings (i) 'Sree Kumar' and (iv) 'Sreekumar' only (LIKE ignores the case in MySQL). None of the given options lists exactly these two strings.

Exam Tips:

a) % in front of a word means "ends with that word".
b) Check each string one by one: only strings whose last characters are "kumar" match.

 

Question 48: List any five built-in functions of SQL and the value returned by each.

Answer:

These are the aggregate functions:
1) SUM() - finds the total of a column.
2) AVG() - finds the average of a column.
3) MIN() - finds the smallest value of a column.
4) MAX() - finds the largest value of a column.
5) COUNT() - finds the number of values in a column.

Exam Tips:

a) Write the function name and what it returns for each of the five.

 

Question 49: Distinguish between the WHERE clause and the HAVING clause.

Answer:

The WHERE clause is used to specify a condition on individual rows.
Syntax: SELECT * FROM Student WHERE roll = 1;
Example output of SELECT * FROM student WHERE roll = 6; is the single row (6, Christy, F) from the student table with the columns roll, name and sex.
The HAVING clause is used with GROUP BY to give conditions on groups of records, not on individual rows.
Example: SELECT sex, COUNT(*) FROM student GROUP BY sex HAVING sex = 'M'; gives the output sex = M and count = 5.

Exam Tips:

a) WHERE filters rows before grouping; HAVING filters groups after GROUP BY.
b) Give one example query for each clause.

 

Question 50: Write any four DML commands in SQL.

Answer:

The four DML commands are:
1) INSERT
2) UPDATE
3) SELECT
4) DELETE

Exam Tips:

a) CREATE, ALTER and DROP belong to DDL, not DML.

 

Question 51: Write the essential clause required for each of the following SQL commands.
a) Insert Into
b) Select
c) Update

Answer:

a) INSERT INTO - VALUES
b) SELECT - FROM
c) UPDATE - SET

Exam Tips:

a) Learn these three pairs together; they are asked repeatedly.

 

Question 52: Consider the given table Customer and write the output of the following SQL queries:

Acc.NoNameBranchAmount
1001KumarCalicut10000
1002SalimTrivandrum20000
1003FidaKottayam18000
1004JohnKannur30000
1005RajuThrissur5000

a) SELECT * FROM customer WHERE Amount > 25000;
b) SELECT Name FROM customer WHERE Branch IN ('Calicut', 'Kannur');
c) SELECT COUNT(*) FROM customer WHERE Amount < 20000;
d) SELECT Name FROM customer WHERE Name LIKE '%m%';
e) SELECT * FROM customer ORDER BY Amount DESC;

Answer:

a) One row: 1004, John, Kannur, 30000
b) Two names: Kumar and John
c) 3 (the amounts 10000, 18000 and 5000 are less than 20000)
d) Two names: Kumar and Salim
e) All five rows in descending order of Amount:

AccNoNameBranchAmount
1004JohnKannur30000
1002SalimTrivandrum20000
1003FidaKottayam18000
1001KumarCalicut10000
1005RajuThrissur5000

Exam Tips:

a) Check each row against the condition one by one before writing the output.
b) '%m%' matches any name that contains the letter m (Kumar, Salim).
c) Show the column headings in the output tables.

 

Question 53: Distinguish between COUNT(*) and COUNT(column-name).

Answer:

COUNT(column-name) finds the number of non-null values in that column.
COUNT(*) finds the number of records (rows) in the table, counting every row that has at least one non-null field.

Exam Tips:

a) The key point is how null values are treated: COUNT(column) skips them.

 

Question 54: Consider the given table ITEMS.

ItemCodeNameCategoryUnitPriceSalesPrice
0001PencilStationery5.008.00
0002PenStationery8.0010.00
0003NoteBookStationery10.0020.00
0004ChappalFootwear50.0070.00
0005AppleFruits60.0090.00
0006OrangeFruits40.0060.00
0007PenStationery10.0012.00

a) Suggest a suitable primary key for the above table. Give justification.
b) Write SQL statements for the following:
i) To list all stationery items.
ii) To list the item code, name and profit of all items.
iii) To count the number of items in each category.
iv) To list all stationery items in descending order of their unit price.
v) To find the item with the highest selling price.
vi) To create a view that contains the details of all stationery items.

Answer:

a) ItemCode is the suitable primary key, because its value is different for every item. Name cannot be the key as it repeats (Pen appears twice).
b) (i) SELECT DISTINCT name FROM ITEMS WHERE Category = 'Stationery';
Output: Pencil, Pen, NoteBook
(ii) SELECT ItemCode, Name, (SalesPrice - UnitPrice) FROM ITEMS;
Output (profit): 0001 Pencil 3.00; 0002 Pen 2.00; 0003 NoteBook 10.00; 0004 Chappal 20.00; 0005 Apple 30.00; 0006 Orange 20.00; 0007 Pen 2.00
(iii) SELECT Category, COUNT(*) FROM ITEMS GROUP BY Category;
Output: Footwear 1, Fruits 2, Stationery 4
(iv) SELECT name, UnitPrice FROM ITEMS WHERE Category = 'Stationery' ORDER BY UnitPrice DESC;
Output: NoteBook 10.00, Pen 10.00, Pen 8.00, Pencil 5.00
(v) SELECT name FROM ITEMS WHERE SalesPrice = (SELECT MAX(SalesPrice) FROM ITEMS);
Output: Apple
(vi) CREATE VIEW UItems AS SELECT * FROM ITEMS WHERE Category = 'Stationery';
SELECT * FROM UItems; shows the four stationery items (0001 Pencil, 0002 Pen, 0003 NoteBook, 0007 Pen).

Exam Tips:

a) Profit is SalesPrice minus UnitPrice; write it as an expression in the SELECT list.
b) A primary key must have a unique value for every row, so a repeating column such as Name or Category cannot be used.
c) A view stores only the query, so it always shows the current data of the base table.

 

Question 55: What are the different modifications that can be made to the structure of a table? Which is the SQL command required for this? Specify the clauses needed for each type of modification.

Answer:

The ALTER TABLE command is used to modify an existing column or to add a new column to an existing table. The keywords used are ADD and MODIFY.
1) A new column can be added to the existing table using the syntax
ALTER TABLE <table name> ADD (<column name> <type> <constraint>);
2) An existing column can be changed in terms of type or size using the syntax
ALTER TABLE <table name> MODIFY (<column name> <new type>);

Exam Tips:

a) Name the command (ALTER TABLE) and the two clauses (ADD and MODIFY) clearly.
b) Give the syntax for each modification.

 

Question 56: A table is created in SQL with 10 records. Which SQL command is used to change the values in a column of specified rows? Write the format.

Answer:

The UPDATE command is used.
Syntax: UPDATE <table name> SET <column name> = value WHERE <condition>;

Exam Tips:

a) The WHERE clause selects the specified rows.

 

Question 57: Name the keyword used with the SELECT command to avoid duplication of values in a column.

Answer:

DISTINCT

Exam Tips:

a) Example: SELECT DISTINCT course FROM student;

 

Question 58: Distinguish between DISTINCT and UNIQUE in SQL.

Answer:

DISTINCT is a keyword used with SELECT to avoid duplicate values in the result for a column of a table.
UNIQUE is a constraint that ensures that no two rows have the same value in a column.

Exam Tips:

a) DISTINCT works while retrieving data (query), whereas UNIQUE works while storing data (table constraint).

 

Question 59: Pick the odd one out and give the reason:
a) CREATE
b) SELECT
c) UPDATE
d) INSERT

Answer:

a) CREATE. It is a DDL command, while the others are DML commands.

Exam Tips:

a) Always write the reason: DDL defines structure, DML handles data.

 

Kerala Board Solutions for Class 12 Computer Science Chapter 09 Structured Query Language

Official Kerala Board Solutions for Chapter 09 Structured Query Language

Explore reliable textbook solutions for Chapter 09 Structured Query Language tailored for Class 12 learners. Utilizing these complete exercise answers ensures your preparation aligns exactly with official Kerala Board standards for Computer Science.

Step-by-Step Explanations for Chapter 09 Structured Query Language

Beyond providing final answers, these guides offer step-by-step breakdowns for complex queries in the Class 12 Computer Science module. This approach helps students balance theoretical depth with practical problem-solving skills required for Kerala Board exams.

Next Steps in Your Computer Science Revision

Consistent practice with these solution guides cultivates faster problem-solving habits and clearer logical structuring. For a complete preparation experience, pair these textbook answers with our dedicated revision notes and sample papers for Class 12 Computer Science.

FAQs

Where can I find the latest Kerala Plus Two Computer Science Previous Questions Chapter 9 Structured Query Language for the 2026-27 session?

The complete and updated Kerala Plus Two Computer Science Previous Questions Chapter 9 Structured Query Language is available for free on StudiesToday.com. These solutions for Class 12 Computer Science are as per latest Kerala Board curriculum.

Are the Computer Science Kerala Board solutions for Class 12 updated for the new 50% competency-based exam pattern?

Yes, our experts have revised the Kerala Plus Two Computer Science Previous Questions Chapter 9 Structured Query Language as per 2026 exam pattern. All textbook exercises have been solved and have added explanation about how the Computer Science concepts are applied in case-study and assertion-reasoning questions.

How do these Class 12 Kerala Board solutions help in scoring 90% plus marks?

Toppers recommend using Kerala Board language because Kerala Board marking schemes are strictly based on textbook definitions. Our Kerala Plus Two Computer Science Previous Questions Chapter 9 Structured Query Language will help students to get full marks in the theory paper.

Do you offer Kerala Plus Two Computer Science Previous Questions Chapter 9 Structured Query Language in multiple languages like Hindi and English?

Yes, we provide bilingual support for Class 12 Computer Science. You can access Kerala Plus Two Computer Science Previous Questions Chapter 9 Structured Query Language in both English and Hindi medium.

Is it possible to download the Computer Science Kerala Board solutions for Class 12 as a PDF?

Yes, you can download the entire Kerala Plus Two Computer Science Previous Questions Chapter 9 Structured Query Language in printable PDF format for offline study on any device.