General SQL VII
1.
What is the purpose of the SQL keyword 'HAVING' in a GROUP BY clause?
Filters the result set based on aggregate conditions after grouping
Orders the result set in ascending or descending order
Performs arithmetic operations on the result set
Groups the result set based on a column
2.
Which SQL statement is used to change the name of a column in a table?
CHANGE COLUMN old_column TO new_column IN table_name;
ALTER TABLE table_name RENAME COLUMN old_column TO new_column;
MODIFY COLUMN old_column TO new_column IN table_name;
RENAME COLUMN old_column TO new_column IN table_name;
3.
What does the SQL statement 'SELECT TOP 5 * FROM table_name;' do?
Retrieves random 5 rows from the specified table
Retrieves the last 5 rows from the specified table
Retrieves the first 5 rows from the specified table
Retrieves all rows from the specified table
4.
In SQL, what is the purpose of the EXISTS keyword in a subquery?
Tests whether a subquery returns any rows
Joins two or more tables based on a related column
Orders the result set in ascending or descending order
Performs arithmetic operations on the result set
5.
Which SQL function is used to find the number of characters in a string?
LEN()
CHAR_LENGTH()
LENGTH()
SIZE()
6.
What does the SQL statement 'SELECT * FROM table1 UNION SELECT * FROM table2;' do?
Combines the result sets of two SELECT statements, excluding duplicates
Combines the result sets of two SELECT statements, including duplicates
Filters rows based on a condition after the GROUP BY clause
Orders the result set in ascending or descending order
7.
What is the purpose of the SQL keyword 'WITH CHECK OPTION' in a view?
Performs arithmetic operations on the result set
Filters rows based on a condition after the GROUP BY clause
Specifies the order of the result set
Ensures that all data modifications made through the view meet the specified conditions
8.
Which SQL statement is used to add a default value to an existing column in a table?
ALTER TABLE table_name ALTER COLUMN column_name SET DEFAULT default_value;
ADD DEFAULT default_value TO column_name IN table_name;
MODIFY COLUMN column_name ADD DEFAULT default_value;
CHANGE COLUMN column_name TO default_value IN table_name;
9.
What does the term 'ACID properties' mean in the context of database transactions?
A method of searching for data by directly accessing the data pages
A type of JOIN that retrieves unmatched rows from both tables
A set of properties that ensure the reliability of transactions: Atomicity, Consistency, Isolation, and Durability
A method of sorting the result set
10.
Which SQL statement is used to delete all records from a table without removing the table itself?
DELETE FROM table_name;
REMOVE ALL FROM table_name;
ERASE ALL FROM table_name;
TRUNCATE TABLE table_name;
11.
What is the purpose of the SQL keyword 'LIKE' in a WHERE clause?
Performs arithmetic operations on the result set
Orders the result set in ascending or descending order
Used for pattern matching in a column
Filters rows based on a condition after the GROUP BY clause
12.
Which SQL function is used to find the average value of a numeric column?
SUM()
AVG()
MIN()
MAX()
13.
In SQL, what is the purpose of the INNER JOIN clause?
Updates all rows in the specified table
Retrieves all rows from the specified table
Deletes all rows from the specified table
Combines rows from two or more tables based on a related column
14.
Which SQL statement is used to modify the data type of a column in a table?
ALTER TABLE table_name MODIFY COLUMN column_name new_data_type;
CHANGE COLUMN column_name TO new_data_type IN table_name;
MODIFY COLUMN column_name TO new_data_type IN table_name;
ALTER TABLE table_name CHANGE COLUMN column_name new_data_type;
15.
What is the purpose of the SQL keyword 'FOREIGN KEY' in a CREATE TABLE statement?
Performs arithmetic operations on the result set
Specifies the order of the result set
Defines a foreign key constraint for a column
Filters rows based on a condition after the GROUP BY clause
16.
Which SQL function is used to round a numeric value to the nearest integer or to the specified number of decimal places?
ROUND()
TRUNC()
CEIL()
FLOOR()
17.
Which SQL statement is used to remove a unique constraint from a column in a table?
REMOVE CONSTRAINT unique_constraint_name FROM table_name;
DROP CONSTRAINT unique_constraint_name FROM table_name;
ALTER TABLE table_name DROP CONSTRAINT unique_constraint_name;
ERASE CONSTRAINT unique_constraint_name FROM table_name;
18.
What does the SQL statement 'SELECT COUNT(*) FROM table_name;' do?
Retrieves the first row from the specified table
Counts the total number of rows in the specified table
Deletes all rows from the specified table
Updates all rows in the specified table
19.
Which SQL keyword is used to retrieve only distinct values from a result set?
SINGULAR
UNIQUE
DIFFERENT
DISTINCT
20.
In SQL, what is the purpose of the GROUP BY clause?
Performs arithmetic operations on the result set
Orders the result set in ascending or descending order
Groups rows based on a specified column or columns
Filters rows based on a condition after the GROUP BY clause