50 multiple-choice questions with answers and detailed explanations. Untimed — choose an answer to check it instantly.
0/50 answered0 correct
Question 1 of 50
What is the purpose of the JOIN clause in SQL?
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 2 of 50
Which type of join returns all records from the left table and matched records from the right table?
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 3 of 50
What does the term ‘Normalization’ refer to in database design?
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 4 of 50
Which SQL function is used to compute the total number of unique values in a column?
Correct answer: C) COUNT(DISTINCT)
Explanation: The COUNT(DISTINCT) function counts the number of unique non-NULL values in a specified column.
Question 5 of 50
Which SQL command is used to remove a database from the system?
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 6 of 50
What is an Entity-Relationship Model (ERM) used for?
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 7 of 50
Which SQL keyword is used to specify a default value for a column?
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 8 of 50
In SQL, which command is used to create a new 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 9 of 50
Which SQL function would you use to convert a string to uppercase?
Correct answer: A) UPPER()
Explanation: The UPPER() function converts all lowercase characters in a string to uppercase.
Question 10 of 50
What does the term ‘referential integrity’ refer to in databases?
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 of 50
Which SQL command is used to insert new data into a table?
Correct answer: B) INSERT
Explanation: The INSERT command is used to add new records to a table in a database.
Question 12 of 50
What does the SQL statement ALTER TABLE table_name DROP COLUMN column_name; do?
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 of 50
Which SQL clause is used to limit the number of records returned in a query?
Correct answer: A) LIMIT
Explanation: The LIMIT clause restricts the number of rows returned by a SQL query to a specified count.
Question 14 of 50
What does the HAVING clause do in SQL?
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 of 50
Which SQL function retrieves the current date and time?
Correct answer: B) NOW()
Explanation: The NOW() function retrieves the current date and time from the system clock.
Question 16 of 50
What is the purpose of the ORDER BY clause in a SQL query?
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 of 50
Which SQL command is used to delete a table from a database?
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 of 50
What is the purpose of the GROUP BY clause in SQL?
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 of 50
Which SQL function can be used to find the average of a numeric column?
Correct answer: A) AVG()
Explanation: The AVG() function calculates the average value of a specified numeric column in a SQL query.
Question 20 of 50
Which SQL statement is used to remove specific records from a table?
Correct answer: B) DELETE
Explanation: The DELETE statement is used to remove specific rows from a table based on defined conditions.
Question 21 of 50
Which keyword is used to create a table in SQL?
Correct answer: A) CREATE TABLE
Explanation: The CREATE TABLE command is used to define a new table and its columns in the database.
Question 22 of 50
What does the DISTINCT keyword do in a SQL query?
Correct answer: C) Removes duplicate records
Explanation: The DISTINCT keyword ensures that the result set contains only unique records, eliminating any duplicates.
Question 23 of 50
What is a primary key in a relational database?
Correct answer: B) A column that uniquely identifies each row in a table
Explanation: A primary key is a unique identifier for each row in a table, ensuring that no two rows have the same value in the primary key column(s).
Question 24 of 50
Which SQL function is used to combine multiple string values into a single string?
Correct answer: C) CONCAT()
Explanation: The CONCAT() function combines two or more strings into one single string in SQL.
Question 25 of 50
Which SQL keyword is used to specify the conditions that must be true for records to be selected?
Correct answer: C) WHERE
Explanation: The WHERE clause specifies the criteria that must be met for records to be included in the result set of a query.
Question 26 of 50
What is the purpose of the INSERT INTO statement in SQL?
Correct answer: B) To add new rows to a table
Explanation: The INSERT INTO statement is used to add new records to a specified table in the database.
Question 27 of 50
Which SQL command is used to commit a transaction?
Correct answer: A) COMMIT
Explanation: The COMMIT command is used to save all changes made during the current transaction to the database permanently.
Question 28 of 50
What does the IS NULL condition do in a SQL query?
Correct answer: C) Checks if a value is missing or undefined
Explanation: The IS NULL condition checks whether a value in a column is NULL, indicating the absence of data.
Question 29 of 50
Which SQL statement is used to retrieve data from multiple tables?
Correct answer: D) SELECT
Explanation: The SELECT statement retrieves data from one or more tables, and can be combined with JOIN clauses to access multiple tables.
Question 30 of 50
What is the purpose of the UNION operator in SQL?
Correct answer: B) To combine the results of two SELECT queries into one
Explanation: The UNION operator is used to combine the result sets of two or more SELECT queries into a single result set, eliminating duplicates.
Question 31 of 50
Which SQL command is used to rename a column in a table?
Correct answer: B) ALTER COLUMN
Explanation: The ALTER TABLE command with ALTER COLUMN is used to change the name of an existing column in a table.
Question 32 of 50
Which SQL function can be used to find the minimum value in a column?
Correct answer: B) MIN()
Explanation: The MIN() function retrieves the smallest value from a specified column in SQL.
Question 33 of 50
Which SQL clause allows you to filter records based on aggregated values?
Correct answer: B) HAVING
Explanation: The HAVING clause is used to filter groups of records based on conditions applied to aggregated values.
Question 34 of 50
What is the purpose of the DROP command in SQL?
Correct answer: B) To delete an entire table or database
Explanation: The DROP command is used to permanently remove a table or database from the database management system.
Question 35 of 50
Which SQL command is used to create a new table with defined columns?
Correct answer: C) CREATE TABLE
Explanation: The CREATE TABLE command is used to define a new table along with its columns and data types.
Question 36 of 50
Which SQL function is used to count the number of rows that meet specific criteria?
Correct answer: B) COUNT()
Explanation: The COUNT() function counts the number of rows that meet specified conditions in a SQL query.
Question 37 of 50
What does the TRUNCATE command do in SQL?
Correct answer: B) Deletes all rows from a table without logging individual row deletions
Explanation: The TRUNCATE command removes all rows from a table while preserving its structure, and it does not log individual row deletions.
Question 38 of 50
Which SQL function is used to calculate the total of a numeric column?
Correct answer: B) SUM()
Explanation: The SUM() function calculates the total of all values in a specified numeric column in SQL.
Question 39 of 50
Which SQL command would you use to update existing records in a table?
Correct answer: B) UPDATE
Explanation: The UPDATE command is used to modify existing records in a specified table.
Question 40 of 50
What does the IN operator do in a SQL query?
Correct answer: B) Filters records based on multiple values
Explanation: The IN operator is used to specify multiple values in a WHERE clause, allowing records to be filtered based on whether a column's value matches any value in the specified list.
Question 41 of 50
Which SQL keyword is used to define a unique constraint on a column?
Correct answer: A) UNIQUE
Explanation: The UNIQUE constraint ensures that all values in a column are distinct, preventing duplicate entries.
Question 42 of 50
Which SQL command is used to modify the data type of an existing column in a table?
Correct answer: C) ALTER COLUMN
Explanation: The ALTER TABLE statement with ALTER COLUMN is used to change the data type of an existing column in SQL.
Question 43 of 50
What does the LIKE operator do in a SQL query?
Correct answer: B) Matches a string against a pattern
Explanation: The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.
Question 44 of 50
Which SQL function can be used to extract a substring from a string?
Correct answer: A) SUBSTRING()
Explanation: The SUBSTRING() function extracts a portion of a string based on a specified starting position and length.
Question 45 of 50
Which SQL command is used to define a relationship between tables?
Correct answer: C) FOREIGN KEY
Explanation: The FOREIGN KEY constraint is used to define a relationship between two tables, ensuring referential integrity.
Question 46 of 50
Which SQL function would you use to return the first character of a string?
Correct answer: A) LEFT()
Explanation: The LEFT() function returns the first specified number of characters from a string.
Question 47 of 50
Which SQL command is used to grant access to a user?
Correct answer: B) GRANT
Explanation: The GRANT command assigns specific privileges to a user or role in the database, allowing access to data and operations.
Question 48 of 50
What is the primary purpose of an index in a database?
Correct answer: B) To improve query performance
Explanation: An index improves the speed of data retrieval operations on a database table, making queries more efficient.
Question 49 of 50
Which SQL command is used to remove all rows from a table without removing the table itself?
Correct answer: C) TRUNCATE
Explanation: The TRUNCATE command deletes all rows in a table while keeping the table structure intact.
Question 50 of 50
What does the SQL function ROUND() do?
Correct answer: B) Rounds a numeric value to a specified number of decimal places
Explanation: The ROUND() function is used to round a numeric value to a specified number of decimal places.
Set 5 complete
You scored 0%
0 correct out of 0 answered (50 questions in this set).