General SQL VIII
1.
Which SQL statement is used to delete a table along with its data and structure?
DELETE TABLE table_name;
DROP TABLE table_name;
REMOVE TABLE table_name;
ERASE TABLE table_name;
2.
What is the purpose of the SQL keyword 'COALESCE' in a SELECT statement?
Performs arithmetic operations on the result set
Combines the result sets of two SELECT statements
Orders the result set in ascending or descending order
Returns the first non-null expression among its arguments
3.
What does the SQL statement 'SELECT MAX(salary) FROM employees;' do?
Counts the total number of employees
Retrieves the maximum salary from the employees table
Deletes all rows from the employees table
Updates all rows in the employees table
4.
In SQL, what is the purpose of the UNION operator in a SELECT statement?
Combines the result sets of two SELECT statements, excluding duplicates
Combines the result sets of two SELECT statements, including duplicates
Orders the result set in ascending or descending order
Filters rows based on a condition after the GROUP BY clause
5.
Which SQL function is used to convert a string to uppercase?
CASE_UPPER()
CAPITALIZE()
UPPER()
CONVERT_UPPER()
6.
What is the purpose of the SQL keyword 'CASCADE' in a foreign key constraint?
Filters rows based on a condition after the GROUP BY clause
Orders the result set in ascending or descending order
Performs arithmetic operations on the result set
Specifies that changes to the referenced key automatically propagate to the dependent key
7.
What does the term 'Stored Procedure' refer to in the context of databases?
A method of sorting the result set
A method of searching for data by directly accessing the data pages
A precompiled set of one or more SQL statements that can be executed
A type of JOIN that retrieves unmatched rows from both tables
8.
Which SQL function is used to find the length of a string?
LEN()
CHAR_LENGTH()
LENGTH()
SIZE()
9.
What is the purpose of the SQL keyword 'ROLLUP' in a GROUP BY clause?
Performs arithmetic operations on the result set
Orders the result set in ascending or descending order
Produces subtotals and grand totals for a set of columns
Filters rows based on a condition after the GROUP BY clause
10.
Which SQL statement is used to update values in a column based on a condition in another column?
ALTER table_name SET column1 = value1 WHERE column2 = condition_value;
MODIFY table_name SET column1 = value1 WHERE column2 = condition_value;
CHANGE table_name SET column1 = value1 WHERE column2 = condition_value;
UPDATE table_name SET column1 = value1 WHERE column2 = condition_value;
11.
In SQL, what does the term 'Cross Join' mean?
Combines each row from the first table with every row from the second table
Retrieves only unmatched rows from both tables
Filters rows based on a condition after the GROUP BY clause
Orders the result set in ascending or descending order
12.
What is the purpose of the SQL keyword 'NOCOUNT' in a stored procedure?
Performs arithmetic operations on the result set
Orders the result set in ascending or descending order
Turns off the message indicating the number of rows affected by a T-SQL statement
Filters rows based on a condition after the GROUP BY clause
13.
Which SQL statement is used to add a new column to an existing table?
CREATE COLUMN column_name data_type IN table_name;
ADD COLUMN column_name data_type TO table_name;
ALTER TABLE table_name ADD column_name data_type;
ADD NEW COLUMN column_name data_type TO table_name;
14.
What does the SQL statement 'SELECT ROUND(salary, -3) FROM employees;' do?
Rounds the salary to the nearest hundred
Rounds the salary to the nearest thousand
Rounds the salary to the nearest ten
Rounds the salary to the nearest integer
15.
Which SQL function is used to find the position of a substring within a string?
CHARINDEX()
POSITION()
SUBSTRING_INDEX()
LOCATE()
16.
What is the purpose of the SQL keyword 'FETCH' in a cursor?
Retrieves the next row from the result set of a query
Orders the result set in ascending or descending order
Performs arithmetic operations on the result set
Filters rows based on a condition after the GROUP BY clause
17.
Which SQL statement is used to grant SELECT permission on a table to a user?
GRANT PERMISSION SELECT TO user_name ON table_name;
ALLOW SELECT ON table_name FOR user_name;
GRANT SELECT ON table_name TO user_name;
PERMIT SELECT ON table_name TO user_name;
18.
In SQL, what is the purpose of the ROWID pseudo column?
Orders the result set in ascending or descending order
Counts the total number of rows in a table
Represents the unique identifier for a row in a table
Performs arithmetic operations on the result set
19.
Which SQL statement is used to remove a table from the database without deleting its structure?
DELETE TABLE table_name;
DROP TABLE table_name;
REMOVE TABLE table_name;
ERASE TABLE table_name;
20.
What does the SQL statement `SELECT LTRIM(' SQL '); ` do?
Leaves the string unchanged
Removes trailing spaces from the string
Removes both leading and trailing spaces from the string
Removes leading spaces from the string