a) A value of zero b) A blank string c) An unknown or missing value d) A default value
Correct Answer: c) An unknown or missing value
Explanation: NULL represents a missing or undefined value in SQL, indicating the absence of data.
Question 22
Which SQL statement is used to remove a column from a table?
a) DELETE COLUMN b) REMOVE COLUMN c) DROP COLUMN d) ALTER COLUMN
Correct Answer: c) DROP COLUMN
Explanation: The DROP COLUMN statement is used to remove a specified column from an existing table.
Question 23
Which SQL operator is used to match a string against a specified pattern?
a) IN b) LIKE c) EXISTS d) BETWEEN
Correct Answer: b) LIKE
Explanation: The LIKE operator is used to search for a specified pattern in a column, often using wildcards.
Question 24
Which SQL function is used to return the total count of rows in a result set?
a) TOTAL() b) COUNT() c) SUM() d) NUMBER()
Correct Answer: b) COUNT()
Explanation: The COUNT() function is utilized to return the number of rows in a result set, including those that are non-NULL.
Question 25
What is the purpose of the TRUNCATE command in SQL?
a) To remove a table from the database b) To delete all rows from a table without removing the table structure c) To drop a database d) To delete specific rows based on a condition
Correct Answer: b) To delete all rows from a table without removing the table structure
Explanation: The TRUNCATE command deletes all rows from a table while keeping the table's structure for future use.
Question 26
Which SQL statement is used to add a new column to an existing table?
a) ALTER TABLE ADD COLUMN b) ADD COLUMN c) UPDATE TABLE d) MODIFY TABLE
Correct Answer: a) ALTER TABLE ADD COLUMN
Explanation: The ALTER TABLE command is used with the ADD COLUMN clause to introduce a new column in an existing table.
Question 27
Which SQL clause is used to return only unique records from a query?
a) DISTINCT b) UNIQUE c) GROUP BY d) HAVING
Correct Answer: a) DISTINCT
Explanation: The DISTINCT clause ensures that the result set contains only unique records, removing duplicates.
Question 28
Which SQL function returns the total sum of a numeric column?
a) TOTAL() b) SUM() c) AVG() d) COUNT()
Correct Answer: b) SUM()
Explanation: The SUM() function calculates the total sum of values in a specified numeric column.
Question 29
What does a composite primary key consist of?
a) One column b) Multiple columns c) Foreign key relationships d) Indexes
Correct Answer: b) Multiple columns
Explanation: A composite primary key consists of two or more columns used together to uniquely identify each row in a table.
Question 30
Which SQL command is used to remove a table from a database?
a) DELETE TABLE b) DROP TABLE c) REMOVE TABLE d) TRUNCATE TABLE
Correct Answer: b) DROP TABLE
Explanation: The DROP TABLE command is used to permanently delete a table and all of its data from the database.
Question 31
Which SQL function is used to concatenate two strings?
a) CONCAT() b) JOIN() c) MERGE() d) ADD()
Correct Answer: a) CONCAT()
Explanation: The CONCAT() function is used to join two or more strings together in SQL.
Question 32
Which keyword is used in SQL to specify the condition that must be met for records to be selected?
a) WHERE b) HAVING c) ORDER BY d) LIMIT
Correct Answer: a) WHERE
Explanation: The WHERE clause specifies the condition that must be met for records to be included in the result set of a query.
Question 33
What does the SQL keyword DEFAULT do?
a) Specifies a default value for a column b) Removes a default value c) Sets a default user d) Creates a default table
Correct Answer: a) Specifies a default value for a column
Explanation: The DEFAULT keyword allows you to specify a default value for a column, which is used if no value is provided during an INSERT operation.
Question 34
In SQL, which command is used to grant privileges to a user?
a) GRANT b) ALLOW c) PERMIT d) ENABLE
Correct Answer: a) GRANT
Explanation: The GRANT command is used to assign specific privileges to a user or role in the database.
Question 35
Which SQL statement is used to retrieve data from one or more tables?
a) SELECT b) GET c) FETCH d) RETRIEVE
Correct Answer: a) SELECT
Explanation: The SELECT statement is used to query and retrieve data from one or more tables in a database.
Question 36
Which SQL command is used to remove rows from a table?
a) DROP b) REMOVE c) DELETE d) TRUNCATE
Correct Answer: c) DELETE
Explanation: The DELETE command is used to remove specific rows from a table based on specified conditions.
Question 37
Which SQL clause is used to define the table from which to retrieve data?
a) FROM b) WHERE c) SELECT d) ORDER BY
Correct Answer: a) FROM
Explanation: The FROM clause specifies the table(s) from which data will be retrieved in a SQL query.
Question 38
What does the term ‘NULL’ mean in a database?
a) A zero value b) An unknown or missing value c) A blank string d) A default value
Correct Answer: b) An unknown or missing value
Explanation: NULL represents a value that is undefined or absent in a database, indicating that the data is missing.
Question 39
Which SQL command is used to create an index on a table?
a) ADD INDEX b) CREATE INDEX c) NEW INDEX d) DEFINE INDEX
Correct Answer: b) CREATE INDEX
Explanation: The CREATE INDEX command is used to create an index on one or more columns in a table to improve query performance.
Question 40
In SQL, which function returns the total number of rows in a result set, including NULL values?
a) COUNT() b) SUM() c) TOTAL() d) ROWS()
Correct Answer: a) COUNT()
Explanation: The COUNT() function returns the total number of rows in a result set, including rows with NULL values, when used with an asterisk (*).