CS Class 12 UT-ii
CS Class 12 UT-ii
1. ______ command is used to remove primary key from the table in SQL.
(a) update (b)remove (c) alter (d)drop
2. Which of the following commands will delete the table from MYSQL database?
(a) DELETE TABLE (b) DROP TABLE (c) REMOVE TABLE (d) ALTER TABLE
3. _________ is a non-key attribute, whose values are derived from the primary key of
some other table.
(a) Primary Key (b) Foreign Key (c) Candidate Key (d) Alternate Key
4. Fill in the blank: The SELECT statement when combined with __________ clause, returns
records without repetition.
(a) DESCRIBE (b) UNIQUE (c) DISTINCT (d) NULL
5. Which function is used to display the total number of records from table in a database?
(a) sum(*) (b) total(*) (c) count(*) (d) return(*)
6. Which of the following is a DDL command?
a) SELECT b) ALTER c) INSERT d) UPDATE
7. Which of the following types of table constraints will prevent the entry of duplicate
rows?
a) Unique b) Distinct c) Primary Key d) NULL
8. Which of the following data types can store text values in MySQL?
a. INT b. FLOAT c. CHAR d. VARCHAR
9. Which of the following statements is used to insert data into a MySQL table?
10. Which of the following clauses is used to sort the result set in ascending or
descending order in MySQL?
SECTION-B
11.Categorize following commands into DDL and DML commands? INSERT INTO, DROP
TABLE, ALTER TABLE, UPDATE...SET 1
12.Write queries (a) to (d) based on the tables EMPLOYEE and DEPARTMENT given below:
2x4
1x4
Table: FURNITURE
(a) SELECT SUM(DISCOUNT) FROM FURNITURE WHERE COST>15000;
(b) SELECT MAX(DATEOFPURCHASE) FROM FURNITURE;
(c) SELECT * FROM FURNITURE WHERE DISCOUNT>5 AND FID LIKE "T%";
(d) SELECT DATEOFPURCHASE FROM FURNITURE WHERE NAME IN ("Dining Table",
"Console Table");
16. Write the output of the queries (i) to (iv) based on the table, TECH_COURSE given
below: 1x4
17. Write the outputs of the SQL queries (i) to (iv) based on the relations Teacher and
Placement given below: 1x4
(i) SELECT Department, avg(salary) FROM Teacher GROUP BY Department;
(ii) SELECT MAX(Date_of_Join),MIN(Date_of_Join) FROM Teacher;
(iii) SELECT Name, Salary, T.Department, Place FROM Teacher T, Placement P WHERE
T.Department = P.Department AND Salary>20000;
(iv) SELECT Name, Place FROM Teacher T, Placement P WHERE Gender =’F’ AND
T.Department=P.Department;
18. (a) Write SQL queries for (i) to (iv), which are based on the table: STUDENT 2x4
(i) To display the records from table student in alphabetical order as per the name of the
student.
(ii) To display Class, Dob and City whose marks is between 450 and 551.
(iii) To display Name, Class and total number of students who have secured more than 450
marks, class wise.
(iv) To increase marks of all students by 20 whose class is “XII”
(b) Write a output for SQL queries (i) to (iii), which are based on the above table: STUDENT 3
(i) SELECT COUNT(*), City FROM STUDENT GROUP BY CITY HAVING COUNT(*)>1;