General SQL X
1.
Which SQL function is used to find the total sum of a numeric column?
ADD()
TOTAL()
SUM()
AGGREGATE()
2.
In SQL, what does the term 'Self-Join' mean?
A type of JOIN that retrieves unmatched rows from both tables
A query in which a table is joined with itself
A method of searching for data by directly accessing the data pages
A method of sorting the result set
3.
What is the purpose of the SQL keyword 'ALL' in a subquery?
Orders the result set in ascending or descending order
Compares a value to all values returned by the subquery
Performs arithmetic operations on the result set
Filters rows based on a condition after the GROUP BY clause
4.
Which SQL statement is used to add a foreign key constraint to a column in an existing table?
CREATE FOREIGN KEY CONSTRAINT foreign_key_constraint_name ON table_name(column_name) REFERENCES referenced_table(ref_column);
ADD FOREIGN KEY CONSTRAINT foreign_key_constraint_name TO table_name(column_name) REFERENCES referenced_table(ref_column);
ALTER TABLE table_name ADD CONSTRAINT foreign_key_constraint_name FOREIGN KEY (column_name) REFERENCES referenced_table(ref_column);
MODIFY TABLE table_name ADD FOREIGN KEY CONSTRAINT foreign_key_constraint_name(column_name) REFERENCES referenced_table(ref_column);
5.
What does the SQL statement 'SELECT COALESCE(NULL, 'Default Value');' do?
Counts the total number of rows
Returns NULL as 'Default Value' is replaced with the specified default value
Retrieves the first non-null expression among its arguments
Returns 'Default Value' as NULL is replaced with the specified default value
6.
Which SQL function is used to find the lowest value in a numeric column?
MIN()
LOW()
BOTTOM()
MINIMUM()
7.
What is the purpose of the SQL keyword 'CHECK' in a CREATE TABLE statement?
Orders the result set in ascending or descending order
Specifies a condition that must be satisfied for a row to be entered into the table
Performs arithmetic operations on the result set
Filters rows based on a condition after the GROUP BY clause
8.
Which SQL statement is used to remove a foreign key constraint from a column in an existing table?
REMOVE FOREIGN KEY CONSTRAINT foreign_key_constraint_name FROM table_name;
ALTER TABLE table_name DROP CONSTRAINT foreign_key_constraint_name;
DELETE FOREIGN KEY CONSTRAINT foreign_key_constraint_name FROM table_name;
DROP FOREIGN KEY CONSTRAINT foreign_key_constraint_name FROM table_name;
9.
Which SQL function is used to convert a numeric value to a string?
CAST()
CONVERT()
TO_STRING()
STRINGIFY()
10.
In SQL, what is the purpose of the 'EXISTS' keyword in a subquery?
Orders the result set in ascending or descending order
Tests for the existence of any rows in the subquery result set
Performs arithmetic operations on the result set
Groups the result set based on a column
11.
What does the term 'Full Outer Join' mean in the context of SQL?
Retrieves all rows when there is a match in either the left or right table
A type of JOIN that retrieves unmatched rows from both tables
A method of searching for data by directly accessing the data pages
A method of sorting the result set
12.
Which SQL function is used to find the difference between two dates in months?
DIFF_MONTH(date1, date2)
MONTH_DIFF(date1, date2)
DATEDIFF(MONTH, date1, date2)
MONTHS_BETWEEN(date1, date2)
13.
What does the SQL statement 'SELECT MIN(order_date) FROM orders;' do?
Deletes all rows from the orders table
Counts the total number of orders
Retrieves the earliest order date from the orders table
Updates all rows in the orders table
14.
In SQL, what is the purpose of the 'NVL' function?
Replaces null values with a specified default value
Orders the result set in ascending or descending order
Performs arithmetic operations on the result set
Groups the result set based on a column
15.
What does the term 'Subquery' mean in the context of SQL?
A query nested within another query
A type of JOIN that retrieves unmatched rows from both tables
A method of searching for data by directly accessing the data pages
A method of sorting the result set
16.
Which SQL statement is used to update multiple columns in a table?
UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition;
MODIFY table_name SET column1 = value1, column2 = value2 WHERE condition;
CHANGE table_name SET column1 = value1, column2 = value2 WHERE condition;
ALTER table_name SET column1 = value1, column2 = value2 WHERE condition;
17.
What is the purpose of the SQL keyword 'GRANT' in a database?
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
Provides specific privileges to a user
18.
Which SQL function is used to find the highest value in a numeric column?
HIGH()
MAX()
TOP()
PEAK()
19.
What does the SQL statement 'SELECT LEFT('SQL Server', 3);' do?
Retrieves the leftmost 3 characters from the string 'SQL Server'
Retrieves the rightmost 3 characters from the string 'SQL Server'
Retrieves the middle 3 characters from the string 'SQL Server'
Leaves the string unchanged
20.
Which SQL statement is used to add a unique constraint to a column in an existing table?
CREATE UNIQUE CONSTRAINT unique_constraint_name ON table_name(column_name);
ADD UNIQUE CONSTRAINT unique_constraint_name TO table_name(column_name);
ALTER TABLE table_name ADD CONSTRAINT unique_constraint_name UNIQUE (column_name);
MODIFY TABLE table_name ADD UNIQUE CONSTRAINT unique_constraint_name(column_name);