General SQL IV
1.
What does the SQL statement 'SELECT COUNT(*) FROM table_name;' do?
Counts the number of distinct values in the specified column
Counts the total number of rows in the specified table
Calculates the average value of a numeric column
Counts the number of NULL values in the specified column
2.
In SQL, what is the purpose of the GROUP_CONCAT() function?
Counts the number of distinct values in a column
Calculates the average value of a numeric column
Concatenates the values of a column for each group into a single string
Finds the maximum value in a column
3.
Which SQL statement is used to remove a table from the database?
REMOVE TABLE table_name;
DELETE FROM table_name;
DROP TABLE table_name;
ERASE TABLE table_name;
4.
What is the purpose of the SQL keyword 'HAVING' in a SELECT statement?
Groups the result set based on a column
Orders the result set in ascending or descending order
Performs arithmetic operations on the result set
Filters the result set based on a condition after the GROUP BY clause
5.
Which SQL statement is used to add a unique constraint to a column?
ADD CONSTRAINT unique_constraint_name UNIQUE (column_name) TO table_name;
ALTER TABLE table_name ADD CONSTRAINT unique_constraint_name UNIQUE (column_name);
CREATE UNIQUE CONSTRAINT unique_constraint_name ON table_name(column_name);
ADD UNIQUE CONSTRAINT unique_constraint_name TO column_name ON table_name;
6.
In SQL, what is the purpose of the EXTRACT() function?
Counts the total number of rows in a table
Calculates the average value of a numeric column
Extracts a specific part (e.g., year, month, day) from a date or time value
Concatenates the values of a column for each group
7.
What is the purpose of the SQL keyword 'TRANSACTION'?
Specifies the order of the result set
Filters the result set based on a condition
Defines a set of SQL statements that are executed as a single unit of work
Performs arithmetic operations on the result set
8.
Which SQL data type is used to store a fixed-length string?
VARCHAR
CHAR
TEXT
STRING
9.
What does the SQL statement 'SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column;' do?
Updates all rows in table1 and table2 where the specified columns have matching values
Deletes all rows from table1 and table2 where the specified columns have matching values
Retrieves all columns from both table1 and table2 where the specified columns have matching values
Inserts new rows into table1 and table2 with matching values in the specified columns
10.
Which SQL function is used to find the length of a text or varchar column?
LENGTH()
CHAR_LENGTH()
LEN()
SIZE()
11.
What is the purpose of the SQL keyword 'GRANT'?
Removes specific privileges from a user
Gives specific privileges to a user
Creates a new user account
Deletes a user account
12.
Which SQL statement is used to update values in a table based on a condition?
MODIFY table_name SET column1 = value1 WHERE condition;
UPDATE table_name SET column1 = value1 WHERE condition;
ALTER table_name SET column1 = value1 WHERE condition;
CHANGE table_name SET column1 = value1 WHERE condition;
13.
What is the purpose of the SQL function COALESCE()?
Returns the first non-null expression in a list
Concatenates the values of a column for each group
Counts the total number of rows in a table
Calculates the average value of a numeric column
14.
Which SQL statement is used to remove a primary key constraint from a column?
ERASE PRIMARY KEY CONSTRAINT primary_key_constraint_name FROM table_name;
DROP CONSTRAINT primary_key_constraint_name FROM table_name;
REMOVE PRIMARY KEY CONSTRAINT primary_key_constraint_name FROM table_name;
ALTER TABLE table_name DROP CONSTRAINT primary_key_constraint_name;
15.
In SQL, what does the term 'Self-Join' mean?
A join between two unrelated tables
A join where a table is joined with itself
A join using the INNER JOIN clause
A join using the OUTER JOIN clause
16.
What is the purpose of the SQL keyword 'LIKE' in a SELECT statement?
To filter rows based on a condition after the GROUP BY clause
To search for a specified pattern in a column
To calculate the average value of a numeric column
To group rows based on a specified column
17.
Which SQL statement is used to retrieve the last n rows from a table?
SELECT * FROM table_name WHERE rownum <= n;
SELECT * FROM table_name ORDER BY column_name DESC LIMIT n;
FETCH LAST n ROWS FROM table_name;
SELECT * FROM table_name TOP n;
18.
What is the purpose of the SQL function UPPER()?
Converts a string to lowercase
Converts a string to uppercase
Calculates the average value of a numeric column
Counts the total number of rows in a table
19.
Which SQL statement is used to retrieve unique values from multiple columns?
SELECT UNIQUE column1 FROM table_name ORDER BY column2;
SELECT UNIQUE column1, column2 FROM table_name;
SELECT DISTINCT column1 FROM table_name GROUP BY column2;
SELECT DISTINCT column1, column2 FROM table_name;
20.
What does the term 'Deadlock' mean in the context of SQL transactions?
A constraint that prevents certain operations on a table
A situation where two or more transactions are waiting for each other to release locks, causing them to be in a state of permanent waiting
A situation where a transaction is rolled back due to an error
A type of JOIN that retrieves unmatched rows from both tables