- web.groovymark@gmail.com
- November 7, 2024
Question 01
What is the purpose of the JOIN clause in SQL?
a) To remove duplicates
b) To combine rows from two or more tables based on a related column
c) To filter results from a single table
d) To sort the results of a query
Correct Answer: b) To combine rows from two or more tables based on a related column
Explanation: The JOIN clause is used to retrieve data from multiple tables by combining rows based on a common column between them.
Question 02
Which type of join returns all records from the left table and matched records from the right table?
a) INNER JOIN
b) RIGHT JOIN
c) LEFT JOIN
d) FULL JOIN
Correct Answer: c) LEFT JOIN
Explanation: A LEFT JOIN returns all records from the left table and the matched records from the right table, with NULLs in the place of unmatched records.
Question 03
What does the term ‘Normalization’ refer to in database design?
a) Combining multiple tables into one
b) Organizing data to reduce redundancy and improve data integrity
c) Storing data in a hierarchical format
d) Increasing data duplication for performance
Correct Answer: b) Organizing data to reduce redundancy and improve data integrity
Explanation: Normalization is the process of organizing a database to reduce redundancy and improve data integrity by structuring the data into tables and defining relationships.
Question 04
Which SQL function is used to compute the total number of unique values in a column?
a) COUNT()
b) SUM()
c) COUNT(DISTINCT)
d) UNIQUE()
Correct Answer: c) COUNT(DISTINCT)
Explanation: The COUNT(DISTINCT) function counts the number of unique non-NULL values in a specified column.
Question 05
Which SQL command is used to remove a database from the system?
a) DELETE DATABASE
b) DROP DATABASE
c) REMOVE DATABASE
d) TRUNCATE DATABASE
Correct Answer: b) DROP DATABASE
Explanation: The DROP DATABASE command is used to permanently remove a database and all its associated tables from the database management system.
Question 06
What is an Entity-Relationship Model (ERM) used for?
a) To store data in a database
b) To visualize database structures and relationships
c) To query data from a database
d) To enforce database constraints
Correct Answer: b) To visualize database structures and relationships
Explanation: An Entity-Relationship Model (ERM) is a conceptual representation of data that illustrates the entities, relationships, and attributes within a database.
Question 07
Which SQL keyword is used to specify a default value for a column?
a) DEFAULT
b) SET
c) ASSIGN
d) VALUE
Correct Answer: a) DEFAULT
Explanation: The DEFAULT keyword allows you to specify a default value for a column that will be used when no value is provided during an INSERT operation.
Question 08
In SQL, which command is used to create a new view?
a) CREATE VIEW
b) NEW VIEW
c) DEFINE VIEW
d) ADD VIEW
Correct Answer: a) CREATE VIEW
Explanation: The CREATE VIEW statement is used to define a new view based on the result of a SELECT query, providing a simplified way to access data.
Question 09
Which SQL function would you use to convert a string to uppercase?
a) UPPER()
b) UCASE()
c) CAPITALIZE()
d) TO_UPPER()
Correct Answer: a) UPPER()
Explanation: The UPPER() function converts all lowercase characters in a string to uppercase.
Question 10
What does the term ‘referential integrity’ refer to in databases?
a) The uniqueness of data in a table
b) The accuracy and consistency of data between related tables
c) The organization of data within a single table
d) The redundancy of data across multiple tables
Correct Answer: b) The accuracy and consistency of data between related tables
Explanation: Referential integrity ensures that relationships between tables remain consistent, meaning that foreign keys must match primary keys in related tables or be NULL.
Question 11
Which SQL command is used to insert new data into a table?
a) ADD
b) INSERT
c) PUT
d) NEW
Correct Answer: b) INSERT
Explanation: The INSERT command is used to add new records to a table in a database.
Question 12
What does the SQL statement ALTER TABLE table_name DROP COLUMN column_name; do?
a) Deletes the entire table
b) Removes a specific column from the table
c) Renames a column
d) Modifies a column’s data type
Correct Answer: b) Removes a specific column from the table
Explanation: The statement removes the specified column from the existing table structure, along with its data.
Question 13
Which SQL clause is used to limit the number of records returned in a query?
a) LIMIT
b) TOP
c) RANK
d) FETCH
Correct Answer: a) LIMIT
Explanation: The LIMIT clause restricts the number of rows returned by a SQL query to a specified count.
Question 14
What does the HAVING clause do in SQL?
a) Filters rows before grouping
b) Filters groups after aggregation
c) Sorts the results
d) Joins two tables
Correct Answer: b) Filters groups after aggregation
Explanation: The HAVING clause is used to filter results after aggregation has taken place, allowing conditions on grouped data.
Question 15
Which SQL function retrieves the current date and time?
a) CURRENT_DATE()
b) NOW()
c) GETDATE()
d) SYSDATE()
Correct Answer: b) NOW()
Explanation: The NOW() function retrieves the current date and time from the system clock.
Question 16
What is the purpose of the ORDER BY clause in a SQL query?
a) To sort the result set
b) To filter results
c) To limit the number of rows
d) To group rows with similar values
Correct Answer: a) To sort the result set
Explanation: The ORDER BY clause is used to sort the result set of a SQL query based on specified columns.
Question 17
Which SQL command is used to delete a table from a database?
a) REMOVE TABLE
b) DELETE TABLE
c) DROP TABLE
d) TRUNCATE TABLE
Correct Answer: c) DROP TABLE
Explanation: The DROP TABLE command is used to permanently remove a table and all its data from the database.
Question 18
What is the purpose of the GROUP BY clause in SQL?
a) To filter records
b) To aggregate data
c) To sort results
d) To define relationships
Correct Answer: b) To aggregate data
Explanation: The GROUP BY clause groups rows that have the same values in specified columns, allowing for aggregate functions to be applied to each group.
Question 19
Which SQL function can be used to find the average of a numeric column?
a) AVG()
b) MEAN()
c) AVERAGE()
d) TOTAL()
Correct Answer: a) AVG()
Explanation: The AVG() function calculates the average value of a specified numeric column in a SQL query.
Question 20
Which SQL statement is used to remove specific records from a table?
a) REMOVE
b) DELETE
c) DROP
d) TRUNCATE
Correct Answer: b) DELETE
Explanation: The DELETE statement is used to remove specific rows from a table based on defined conditions.