CHAPTER 9
STRUCTURED QUERY LANGUAGE
1. Which MySQL data type is fixed length and pads unused space with blanks? (easy)
a. CHAR(n)
b. VARCHAR(n)
c. TEXT
d. STRING
2. What is the maximum length allowed for a VARCHAR data type in MySQL? (easy)
a. 32,767
b. 65,535
c. 1,024
d. 255
3. Which data type should be used in MySQL to store values larger than 4,294,967,295?
(average)
a. BIGINT
b. FLOAT
c. INT
d. DOUBLE
4. Which MySQL data type is suitable for storing dates in the format 'YYYY-MM-DD’?
(easy)
a. DATETIME
b. TIME
c. TIMESTAMP
d. DATE
5. How many bytes does a FLOAT data type occupy in MySQL?
(easy)
a. 2 bytes
b. 4 bytes
c. 8 bytes
d. 16 bytes
6. Why might a developer prefer VARCHAR over CHAR for storing names?(average)
a. VARCHAR is faster for indexing
b. CHAR wastes space for variable-length strings
c. CHAR supports Unicode while VARCHAR does not
d. VARCHAR automatically converts to uppercase
SUBJECT: 41 COMPUTER SCIENCE Page 145 of 255
7. A school database stores student roll numbers. Which data type is most appropriate and
why?(difficult)
a. VARCHAR
b. CHAR
c. INT
d. DATE
8. A developer uses CHAR(10) to store student names. What is the possible drawback of this
choice?(difficult)
a. CHAR does not support special characters
b. CHAR automatically converts text to uppercase
c. CHAR always stores exactly 10 characters, wasting space
d. CHAR cannot store numeric values
9. Why might VARCHAR be preferred over CHAR for storing student addresses?(difficult)
a. CHAR cannot store space
b. VARCHAR is faster for searching
c. VARCHAR stores only the actual length of the string
d. CHAR is limited to 10 characters
10. A student’s age is stored using the INT data type. What kind of operations can be
performed on this data? (average)
e. Arithmetic operations
f. Text alignment
g. Date formatting
h. Concatenation
11. Which of the following is a relational database management system?(easy)
a. MongoDB
[Link]
c. No SQL
[Link] Database
12. Which SQL statement is used to retrieve data from a database?(easy)
a. INSERT.
[Link]
c. SELECT
[Link]
SUBJECT: 41 COMPUTER SCIENCE Page 146 of 255
13. Which of the following is true about SQL?(average/)
a. SQL is case-sensitive
b. SQL is used only for data retrieval
c. SQL uses procedural logic
d. SQL uses English-like syntax
14. Which prompt indicates that MySQL is ready to accept SQL statements?(easy)
a. SQL>
b. mysql>
c. cmd>
d. db>
15. Which of the following is a fixed-length character data type in MySQL? (easy)
a. VARCHAR
b. CHAR
c. TEXT
d. STRING
16. Which constraint ensures that a column cannot have missing or unknown
values?(average)
a. UNIQUE
b. DEFAULT
c. NOT NULL
d. FOREIGN KEY
17. Which two constraints restricts range for column values?(easy)
a. UNIQUE
b. DEFAULT
c. PRIMARY KEY
d. CHECK
18. Which SQL command displays the structure of a table?(easy)
e. SHOW TABLE
f. DESCRIBE
g. STRUCTURE
h. VIEW TABLE
19. Which statement is used to add a new column to an existing table?(easy)
a. MODIFY COLUMN
b. ADD COLUMN TO
c. ALTER TABLE ADD
d. INSERT INTO TABLE
SUBJECT: 41 COMPUTER SCIENCE Page 147 of 255
20. Which constraint ensures that no two rows have the same value in a column? (easy)
e. NOT NULL
f. PRIMARY KEY
g. UNIQUE
h. FOREIGN KEY
21. Which of the following is true about foreign keys? (average)
a. They must reference a primary key or unique key in
another table.
b. They must always contain non-NULL values.
c. They enforce uniqueness in the referencing column.
d. They can reference columns with duplicate values
22. Which one of the following SQL command is used to insert new records into a table?
(easy)
a. ADD
b. INSERT
c. UPDATE
d. SELECT
23. Which of the following is part of Data Manipulation Language (DML)?(easy)
a. CREATE
b. ALTER
c. DELETE
d. DROP
24. What should be ensured before inserting a record with a foreign key?(average)
a. The referenced table must be empty
b. The referenced table must be populated.
c. The foreign key must be NULL.
d. The foreign key must be unique
25. Which format is used to store date values in MySQL? (easy)
a. DD-MM-YYYY
b. MM-DD-YYYY
c. YYYY-MM-DD
d. DD/YYYY/MM
26. Which one of the SQL clause used to filter records based on a condition?(easy)
e. FROM
f. SELECT
g. WHERE.
SUBJECT: 41 COMPUTER SCIENCE Page 148 of 255
h. HAVING
27. The keyword to rename a column in the output of a select query?(easy)
a. RENAME
b. TITLE
c. AS
d. ALIAS
28. Which clause ensures that duplicate values are not shown in the query result? (average)
a. UNIQUE
b. DISTINCT
c. ORDER BY
d. GROUP BY
29. Which operator is used to define a range in SQL queries?(average/understanding)
a. BETWEEN
b. WITHIN
c. LIMIT
d. IN
30. What does the ORDER BY clause do in SQL?
(average/understanding)
a. Sorts rows based on column values
b. Filters rows based on conditions
c. Groups rows with similar values
d. Limits the number of rows returned
31. Which operator is used to check for missing or unknown values in SQL?(easy)
a. NOT
b. NOT EXISTS
c. IS NULL
d. IN
32. The SQL operator is used for substring pattern matching is
( average)
a. IN
b. BETWEEN
c. LIKE
d. MATCHES
33. What does the % wildcard represent in SQL? ( average)
a. Exactly one character
b. Matches any single character
SUBJECT: 41 COMPUTER SCIENCE Page 149 of 255
c. Zero, one, or multiple characters
d. Only uppercase letters
34. Which query selects employees whose names start with 'K'?
( average)
a. SELECT * FROM EMPLOYEE WHERE Ename = 'K';
b. SELECT * FROM EMPLOYEE WHERE Ename LIKE '%K';
c. SELECT * FROM EMPLOYEE WHERE Ename LIKE 'K%';
d. SELECT * FROM EMPLOYEE WHERE Ename IN 'K_';
35. What does the query SELECT Ename FROM EMPLOYEE WHERE Ename LIKE
'_a%'; returns?
a. Names starting with 'a'
b. Names with 'a' as the last character
c. Names with 'a' as the second character .
d. Names with exactly two characters (average/Applying)
36. Which wildcard is used to match exactly one character in SQL?
a. %
b. _ C
c. . #
d. D. * (average/ Understanding)
37. Which SQL command is used to modify existing data in a table? (average/understanding)
a. UNION
b. INSERT
c. UPDATE
d. ALTER
38. What will happen if the WHERE clause omitted in an UPDATE statement?
a. No rows updated.
b. It demands condition interactively
c. All rows are updated.
d. Syntax error (average/applying)
39. Which of the following is a correct syntax to update multiple columns in SQL?
(average/applying)
a. UPDATE table SET col1 = val1 AND col2 = val2;
b. UPDATE table SET col1 = val1, col2 = val2;
c. UPDATE table SET (col1, col2) = (val1, val2);
d. MODIFY table SET col1 = val1, col2 = val2.
40. Which SQL statement is used to remove records from a table?
SUBJECT: 41 COMPUTER SCIENCE Page 150 of 255
(average/applying)
a. REMOVE
b. DELETE
c. DROP
d. ERASE
41. What does the ORDER BY clause do in SQL?
(average/understanding)
a. Sorts rows based on column values
b. Filters rows based on conditions
c. Groups rows with similar values
d. Limits the number of rows returned
42. Which operator is used to check for missing or unknown values in SQL?(easy)
a. NOT
b. NOT EXISTS
c. IS NULL
d. IN
43. The SQL operator is used for substring pattern matching is
( average)
a. IN
b. BETWEEN
c. LIKE
d. MATCHES
44. What does the % wildcard represent in SQL? ( average)
a. Exactly one character
b. Matches any single character
c. Zero, one, or multiple characters
d. Only uppercase letters
45. Which query selects employees whose names start with 'K'?
( average)
a. SELECT * FROM EMPLOYEE WHERE Ename = 'K';
b. SELECT * FROM EMPLOYEE WHERE Ename LIKE '%K';
c. SELECT * FROM EMPLOYEE WHERE Ename LIKE 'K%';
d. SELECT * FROM EMPLOYEE WHERE Ename IN 'K_';
46. What does the query SELECT Ename FROM EMPLOYEE WHERE Ename LIKE
'_a%'; returns?
a. Names starting with 'a'
SUBJECT: 41 COMPUTER SCIENCE Page 151 of 255
b. Names with 'a' as the last character
c. Names with 'a' as the second character .
d. Names with exactly two characters (average/Applying)
47. Which wildcard is used to match exactly one character in SQL?
a. %
b. _ C
c. . #
d. D. * (average/ Understanding)
48. Which SQL command is used to modify existing data in a table? (average/understanding)
a. UNION
b. INSERT
c. UPDATE
d. ALTER
49. What will happen if the WHERE clause omitted in an UPDATE statement?
a. No rows updated.
b. It demands condition interactively
c. All rows are updated.
d. Syntax error (average/applying)
50. Which of the following is a correct syntax to update multiple columns in SQL?
(average/applying)
a. UPDATE table SET col1 = val1 AND col2 = val2;
b. UPDATE table SET col1 = val1, col2 = val2;
c. UPDATE table SET (col1, col2) = (val1, val2);
d. MODIFY table SET col1 = val1, col2 = val2.
51. Which SQL statement is used to remove records from a table?
(average/applying)
a. REMOVE
b. DELETE
c. DROP
d. ERASE
52. Which function returns the name of the day from a given date?
(average/understanding)
a. DAY()
b. DAYNAME()
c. DATE()
d. NOW()
SUBJECT: 41 COMPUTER SCIENCE Page 152 of 255
53. What will the query SELECT MONTHNAME('2003-11-28'); return?
(average/applying)
a. 11
b. November
c. 28
d. Friday
54. Which function is used to extract the year from a date?
(average/applying)
a. YEAR()
b. DATE()
c. MONTH()
d. DAY()
55. Which of the following is a multiple row (aggregate) function?
(easy/understanding)
a. ROUND()
b. DAYNAME()
c. MAX()
d. MONTHNAME()
56. What does the query SELECT SUM(SalePrice) FROM SALE WHERE CustID = 'C0001';
do?
(average/understanding)
a. Adds all SalePrice values in the SALE table.
b. Adds SalePrice values for customer C0001.
c. Displays SalePrice for customer C0001.
d. Counts SalePrice entries for customer C0001.
57. Which SQL function returns the average of values in a column?
(easy/understanding)
a. SUM()
b. AVG()
c. COUNT()
d. MAX()
58. What does the COUNT(*) function return?
(easy/understanding)
a. Number of non-null values in a column
b. Number of distinct values
c. Total number of rows in a table
SUBJECT: 41 COMPUTER SCIENCE Page 153 of 255
d. Sum of all numeric values
59. Which function ignores NULL values while counting?
(easy/ Applying)
a. COUNT(*)
b. COUNT(column)
c. SUM(column)
d. MAX(column)
60. What will the query SELECT COUNT(DISTINCT Model) FROM INVENTORY;return?
(average/applying)
a. Total number of models
b. Number of rows in INVENTORY
c. Number of unique model types
d. Number of NULL values in Model
61. Which aggregate function return the largest value in a column?
(easy/understanding)
a. MIN()s
b. MAX()
c. COUNT()
d. AVG()
62. What is the output of SELECT AVG(Price) FROM INVENTORY WHERE Model =
'LXI';?
(average/applying)
a. Average price of all cars
b. Average price of LXI model cars
c. Total price of LXI model cars
d. Number of LXI model cars
63. Which operation combines rows from two tables and removes duplicates?
(easy/understanding)
a. INTERSECT
b. MINUS
c. UNION
d. JOIN
64. What does the INTERSECT operation return?
(average /understanding)
a. All rows from both tables
b. Rows that are present only on the first table.
SUBJECT: 41 COMPUTER SCIENCE Page 154 of 255
c. Common rows from both tables
d. Rows that present only on the second table.
65. Which operation returns rows that are in the first table but not in the second?
(easy/understanding)
a. UNION
b. INTERSECT
c. MINUS
d. SELECT
66. Which of the following conditions must be met to apply UNION, INTERSECT, or
MINUS operations?
(average/apply)
a. Tables must have the same number of rows.
b. Tables must have the same number of columns and matching
data types.
c. Tables must be in sored order.
d. Tables must have primary keys.
67. What will the result of DANCE ∩ MUSIC contain?
(easy/apply)
a. All students from both events
b. Students only in MUSIC
c. Students only in DANCE
d. Students participate in both events.
68. What does the Cartesian product of two tables return?
(easy/understanding)
a. Only matching rows
b. All combinations of rows from both tables
c. Rows with NULL values
d. Duplicate rows only
69. If table A has 4 rows and table B has 5 rows, how many rows the Cartesian product A × B
contain?
(easy/applying)
a. 9
b. 20
c. 4
d. 5
SUBJECT: 41 COMPUTER SCIENCE Page 155 of 255
70. What is the degree of the resulting relation when two Tables of degree three are combined
by Cartesian product?
(average/applying)
a. 3
b. 6
c. 9
d. 12
71. Which clause is used to filter rows after applying Cartesian product based on a
condition?
(easy/remembering)
a. GROUP BY
b. HAVING
c. WHERE.
d. ORDER BY
72. What does the JOIN operation do in SQL?
(easy/understanding)
a. Combines all possible rows from two tables
b. Combines rows from two tables based on a condition
c. Removes duplicate rows from a table
d. Filters rows based on a condition
73. Which JOIN type removes redundant columns when joining two tables with a common
attribute?
(average/understanding)
a. INNER JOIN
b. LEFT JOIN
c. NATURALJOIN
d. CROSS JOIN
74. What is the result of the query SELECT * FROM UNIFORM U JOIN COST C ON
[Link] = [Link];?
(average/applying)
a. Cartesian product of UNIFORM and COST
b. Only rows with matching UCode from both tables
c. All rows from UNIFORM
d. All rows from COST
75. How many JOIN operation are needed to combine N tables using equality condition?
(easy))
SUBJECT: 41 COMPUTER SCIENCE Page 156 of 255
a. N
b. N+1
c. N–1
d. 2
76. Identify the correct date function from the following.(easy)
a. FINDDATE ()
b. JULIANDATE ()
c. NOW ()
d. SYSTEM_DATE ()
77. The SQL command to modify the structure of a table is(easy)
a. CREATE
b. UPDATE
c. INSERT
d. ALTER
78. The most popular query language used by RDBMS is(easy)
a. MYSQL
b. PYTHON
c. C++
d. JAVA
79. Which of the following is a string single row built in function (easy)
a. Length ()
b. Min ()
c. Now ()
d. Count ()
80. Which datatype is used to hold numbers with decimal points in MYSQL?(easy)
a. FLOAT
b. DATE
c. INT
d. INTEGER
81. The clause used to enforce condition is(easy)
a. DISTINCT
b. GROUP BY
SUBJECT: 41 COMPUTER SCIENCE Page 157 of 255
c. ORDER BY
d. WHERE
Fill in the Blanks.(all easy except Q27)
1. A ______ is a collection of related tables used to store and manage data.
2. MySQL is a ______ type of database management system.
3. The SQL command used to create a new table is ______.
4. The ______ statement is used to modify the structure of an existing table.
5. To insert new data into a table, we use the ______ statement.
6. The ______ clause is used to filter rows based on specific conditions.
7. The ______ clause is used to eliminate duplicate values from the result set.
8. The ______ statement is used to change existing data in a table.
9. The ______ operator is used to match values within a specified range.
10. The ______ operator is used to match values from a given list.
11. The ____ clause is used to sort the result of a query in ascending or descending order.
12. The ______ operator is used for pattern matching using wildcards like % and _.
13. A ______ in SQL performs a specific task and returns a single value.
14. ______ row functions operate on individual rows and return one result per row.
15. ______ row functions operate on a group of rows and return a single result.
16. The ______ clause is used to group rows that have the same values in specified columns.
17. The ______ operation combines rows from two or more tables based on common fields.
18. The SQL command used to remove a table from the database is ______.
19. IS NULL and IS NOT NULL are used to test_______
20. The ______ clause is used to apply conditions on grouped data after aggregation.
21. _______clause is used along with select to avoid duplicate values in an SQL query.
22. ________operation is used to combine the selected rows of two tables at a time.
23. ________ is a command which comes under DML.
24. ________ is an aggregate function in SQL
25. ________operator defines the range of values inclusive of boundary values.
26. The function that converts string into uppercase is __________
27. The result of 5+NULL is ____________(average)
Questions carrying 2-marks
1. Name any two popular RDBMS software (easy)
2. What is SQL and why is it widely used in database systems? (average)
3. Is SQL case-sensitive? Justify your answer.(average)
4. List any two types of operations that can be performed using SQL(easy)
5. Define the CHAR and VARCHAR data types. How do they differ?
SUBJECT: 41 COMPUTER SCIENCE Page 158 of 255