General SQL XIV
1.
Which SQL statement is used to create an index on a table?
ADD INDEX index_name TO table_name(column_name);
CREATE INDEX index_name ON table_name(column_name);
INDEX table_name ADD index_name(column_name);
DEFINE INDEX index_name FOR table_name(column_name);
2.
Which SQL function is used to find the maximum value in a set of values?
MAX()
LARGEST()
GREATEST()
MAXIMUM()
3.
Which SQL function is used to find the length of a string including leading and trailing spaces?
CHAR_LENGTH()
LENGTH()
LEN()
SIZE()
4.
Which SQL function is used to convert a date to a string?
CONVERT_TO_STRING()
TO_CHAR()
DATE_TO_STRING()
STRINGIFY_DATE()
5.
Which SQL function is used to convert a numeric value to a character string?
TO_STRING()
CONVERT()
CAST()
NUMERIC_TO_STRING()
6.
Which SQL function is used to calculate the square root of a numeric value?
SQRT()
ROOT()
SQUARE_ROOT()
CALCULATE_SQRT()
7.
What is the purpose of the SQL keyword 'HAVING' in a GROUP BY clause?
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 aggregate conditions after grouping
8.
What does the SQL statement 'SELECT SUBSTRING(column_name, 1, 3) FROM table_name;' do?
Retrieves the first three characters from the specified column
Counts the total number of rows in the table
Deletes all rows from the table
Updates all rows in the table
9.
Which SQL statement is used to retrieve only even values from a column?
RETRIEVE EVEN column_name FROM table_name;
GET EVEN VALUES FROM table_name.column_name;
SELECT column_name FROM table_name WHERE column_name % 2 = 0;
FILTER EVEN VALUES column_name FROM table_name;
10.
What does the term 'Stored Procedure' refer to in the context of SQL?
A precompiled set of one or more SQL statements that can be executed
Sorting data in ascending or descending order
Filtering data based on a condition
Grouping data based on a column
11.
What is the purpose of the SQL keyword 'OFFSET' in a SELECT statement?
Orders the result set in ascending or descending order
Skips a specified number of rows before starting to return rows
Performs arithmetic operations on the result set
Filters rows based on a condition after the GROUP BY clause
12.
Which SQL statement is used to remove all data from a table without removing the table structure?
DELETE FROM table_name;
REMOVE ALL FROM table_name;
TRUNCATE TABLE table_name;
CLEAR TABLE table_name;
13.
In SQL, what does the term 'Self-Join' mean?
A type of JOIN that retrieves unmatched rows from both tables
A join 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
14.
What is the purpose of the SQL keyword 'ROLLBACK' in a transaction?
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
Undoes all changes made during the current transaction
15.
Which SQL statement is used to create a unique constraint on a column in an existing table?
MODIFY TABLE table_name ADD UNIQUE CONSTRAINT unique_constraint_name(column_name);
ADD UNIQUE CONSTRAINT unique_constraint_name TO table_name(column_name);
CREATE UNIQUE CONSTRAINT unique_constraint_name ON table_name(column_name);
ALTER TABLE table_name ADD CONSTRAINT unique_constraint_name UNIQUE (column_name);
16.
What does the SQL statement 'SELECT COALESCE(column_name, 'Default Value') FROM table_name;' do?
Returns the column value if it is not null, otherwise returns 'Default Value'
Returns 'Default Value' if the column value is null, otherwise returns the column value
Retrieves the first non-null expression among its arguments
Counts the total number of rows
17.
What is the purpose of the SQL keyword 'GRANT' in database security?
Orders the result set in ascending or descending order
Provides privileges to users or roles for database objects
Performs arithmetic operations on the result set
Filters rows based on a condition after the GROUP BY clause
18.
Which SQL statement is used to change the data type of a column in an existing 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 SET DATA TYPE new_data_type;
UPDATE TABLE table_name SET DATA TYPE column_name = new_data_type;
19.
What does the term 'Cross Database Join' refer to in the context of SQL?
A method of searching for data by directly accessing the data pages
A type of JOIN that retrieves unmatched rows from both tables
A join operation involving tables from different databases
A method of sorting the result set
20.
Which SQL statement is used to create a view in the database?
DEFINE VIEW view_name AS SELECT column1, column2 FROM table_name;
CREATE VIEW view_name AS SELECT column1, column2 FROM table_name;
CREATE VIEW view_name ON table_name(column1, column2);
MODIFY TABLE table_name CREATE VIEW view_name AS SELECT column1, column2;