Which SQL statement is used to remove all rows from a table without removing the table structure?
Correct answer:
C) TRUNCATE
Explanation: The TRUNCATE statement deletes all rows from a table but retains its structure.
Which SQL statement is used to remove all rows from a table without removing the table structure?
Correct answer:
C) TRUNCATE
Explanation: The TRUNCATE statement deletes all rows from a table but retains its structure.
What is the default value for a column if no value is provided and no default is set?
Correct answer:
B) NULL
Explanation: If no default is provided and no value is given during an insert, the column is set to NULL.
Which SQL statement would you use to add a new column to an existing table?
Correct answer:
C) ALTER TABLE ADD COLUMN
Explanation: The ALTER TABLE ADD COLUMN statement adds a new column to an existing table.
Which SQL function is used to convert a string to uppercase?
Correct answer:
A) UPPER()
Explanation: The UPPER() function converts a string to uppercase.
How do you rename an existing table in SQL?
Correct answer:
C) RENAME TABLE
Explanation: The RENAME TABLE statement is used to rename an existing table.
Which SQL statement is used to combine rows from two or more tables based on a related column between them?
Correct answer:
B) JOIN
Explanation: The JOIN keyword is used to combine rows from two or more tables based on a related column.
What does the SQL clause LIMIT do?
Correct answer:
B) Limits the number of rows returned
Explanation: The LIMIT clause restricts the number of rows returned by a query.
How do you check if a column contains a NULL value in SQL?
Correct answer:
A) WHERE column IS NULL
Explanation: The correct syntax to check for NULL values is WHERE column IS NULL.
Which SQL function returns the number of characters in a string?
Correct answer:
C) LENGTH()
Explanation: The LENGTH() function returns the number of characters in a string.
What is the result of the following expression: SELECT 7 % 3?
Correct answer:
B) 2
Explanation: The modulo operation (%) returns the remainder of the division of 7 by 3, which is 1.
How do you select the unique values from a column in SQL?
Correct answer:
B) SELECT DISTINCT
Explanation: The DISTINCT keyword is used to return only unique values in a query.
Which SQL clause is used to sort the result set in ascending or descending order?
Correct answer:
A) ORDER BY
Explanation: The ORDER BY clause is used to sort the result set in either ascending or descending order.
What is the default sorting order for the ORDER BY clause?
Correct answer:
B) Ascending
Explanation: The default sorting order for ORDER BY is ascending unless otherwise specified.
Which SQL keyword is used to combine the results of two queries into a single result set?
Correct answer:
B) UNION
Explanation: The UNION keyword combines the results of two queries into a single result set, eliminating duplicates.
How do you select all columns from a table in SQL?
Correct answer:
A) SELECT *
Explanation: The SELECT * statement selects all columns from a table.
Which SQL statement is used to delete a table from a database?
Correct answer:
B) DROP TABLE
Explanation: The DROP TABLE statement removes a table and all of its data from a database.
What does the SQL WHERE clause do?
Correct answer:
A) Filters rows based on a condition
Explanation: The WHERE clause is used to filter records based on a specified condition.
Which SQL function returns the sum of all values in a numeric column?
Correct answer:
B) SUM()
Explanation: The SUM() function returns the total sum of a numeric column.
Which SQL keyword is used to remove duplicates in a result set?
Correct answer:
A) DISTINCT
Explanation: The DISTINCT keyword removes duplicate rows in the result set.
How do you rename a column in SQL?
Correct answer:
D) ALTER TABLE RENAME COLUMN
Explanation: The ALTER TABLE RENAME COLUMN statement is used to rename a column in SQL.
What is the purpose of the SQL HAVING clause?
Correct answer:
B) To filter rows after grouping
Explanation: The HAVING clause is used to filter groups based on a condition.
Which SQL clause is used to limit the number of rows returned by a query?
Correct answer:
B) LIMIT
Explanation: The LIMIT clause restricts the number of rows returned by a query.
How do you delete a specific row in SQL where the column "ID" is 10?
Correct answer:
B) DELETE FROM table WHERE ID = 10
Explanation: The DELETE statement is used to delete specific rows based on a condition.
Which SQL statement is used to change the structure of an existing table?
Correct answer:
B) ALTER TABLE
Explanation: The ALTER TABLE statement is used to change the structure of an existing table.
What does the SQL statement CREATE TABLE do?
Correct answer:
A) It creates a new table
Explanation: The CREATE TABLE statement is used to create a new table in the database.
Which SQL keyword is used to filter rows before applying the GROUP BY clause?
Correct answer:
B) WHERE
Explanation: The WHERE clause filters rows before they are grouped by the GROUP BY clause.
What SQL operator is used to test if a value is in a specific list of values?
Correct answer:
A) IN
Explanation: The IN operator tests whether a value matches any value in a list or subquery.
How do you retrieve rows where a column value matches a pattern in SQL?
Correct answer:
A) WHERE column LIKE pattern
Explanation: The LIKE operator is used to search for a specified pattern in a column.
Which SQL function is used to find the minimum value in a column?
Correct answer:
A) MIN()
Explanation: The MIN() function returns the smallest value in a selected column.
What does the SQL function ROUND() do?
Correct answer:
C) Rounds a number to the specified number of decimal places
Explanation: The ROUND() function rounds a number to a specified number of decimal places.
What does the SQL IS NOT NULL condition do?
Correct answer:
B) Selects rows where the column is not NULL
Explanation: The IS NOT NULL condition filters rows where the column does not contain NULL values.
Which SQL function is used to replace NULL values with a specified value?
Correct answer:
B) COALESCE()
Explanation: The COALESCE() function returns the first non-NULL value in a list of expressions.
How do you concatenate two strings in SQL?
Correct answer:
A) CONCAT()
Explanation: The CONCAT() function is used to concatenate two or more strings.
What does the SQL clause EXISTS do?
Correct answer:
A) It checks if a subquery returns any rows
Explanation: The EXISTS keyword checks for the existence of rows in a subquery.
Which SQL operator is used to compare two expressions and return TRUE if they are not equal?
Correct answer:
A) !=
Explanation: The != operator is used to compare two expressions and return TRUE if they are not equal.
What does the SQL clause ORDER BY do?
Correct answer:
A) It sorts the result set
Explanation: The ORDER BY clause sorts the result set in ascending or descending order.
Which SQL clause is used to group rows that have the same values?
Correct answer:
A) GROUP BY
Explanation: The GROUP BY clause groups rows that have the same values into summary rows.
How do you retrieve all rows where a column value is between two values in SQL?
Correct answer:
A) WHERE column BETWEEN value1 AND value2
Explanation: The BETWEEN operator selects values within a given range, inclusive of both endpoints.
What SQL function is used to count the number of rows returned by a query?
Correct answer:
A) COUNT()
Explanation: The COUNT() function returns the number of rows in a query result.
How do you remove a column from an existing table in SQL?
Correct answer:
B) ALTER TABLE DROP COLUMN
Explanation: The ALTER TABLE DROP COLUMN statement is used to remove a column from an existing table.
Which SQL operator is used to match any value in a specified list?
Correct answer:
A) IN
Explanation: The IN operator is used to match any value in a specified list.
Which SQL function is used to return the smallest integer greater than or equal to a given number?
Correct answer:
A) CEILING()
Explanation: The CEILING() function returns the smallest integer greater than or equal to a given number.
What is the result of the following expression: SELECT 10 / 3?
Correct answer:
A) 3.33
Explanation: The division of 10 by 3 results in 3.33.
How do you change the data type of an existing column in SQL?
Correct answer:
B) ALTER TABLE MODIFY COLUMN
Explanation: The ALTER TABLE MODIFY COLUMN statement is used to change the data type of an existing column.
What does the SQL keyword DISTINCT do?
Correct answer:
A) Removes duplicates from the result set
Explanation: The DISTINCT keyword removes duplicate rows from the result set.
Which SQL function is used to convert a string to lowercase?
Correct answer:
A) LOWER()
Explanation: The LOWER() function converts a string to lowercase.
Which SQL keyword is used to specify a condition for joining two tables?
Correct answer:
A) ON
Explanation: The ON keyword is used to specify the condition for joining two tables.
How do you retrieve all rows where a column value is NULL in SQL?
Correct answer:
A) WHERE column IS NULL
Explanation: The correct syntax to retrieve rows where a column value is NULL is WHERE column IS NULL.
Which SQL function is used to return the current system date and time?
Correct answer:
A) NOW()
Explanation: The NOW() function returns the current system date and time.
How do you remove a table from a database in SQL?
Correct answer:
B) DROP TABLE
Explanation: The DROP TABLE statement removes a table and all of its data from a database.
If this exam is giving you a hard time, let us be your helping hand. Contact us, and we'll provide the assistance you need to pass and move forward.