General SQL VI
1.
What is the purpose of the SQL keyword 'TRUNCATE TABLE'?
To delete all rows from a table but retain the table structure
To remove a table from the database
To update values in a table based on a condition
To add a new column to an existing table
2.
Which SQL statement is used to add a foreign key constraint to an existing table?
ALTER TABLE table_name ADD FOREIGN KEY (column_name) REFERENCES reference_table(ref_column);
ADD CONSTRAINT FOREIGN KEY (column_name) TO table_name REFERENCES reference_table(ref_column);
CREATE FOREIGN KEY CONSTRAINT fk_constraint_name ON table_name(column_name) REFERENCES reference_table(ref_column);
ADD FOREIGN KEY CONSTRAINT fk_constraint_name TO column_name ON table_name REFERENCES reference_table(ref_column);
3.
What does the SQL statement 'SELECT * FROM table1 LEFT JOIN table2 ON table1.column = table2.column;' do?
Inserts new rows into table1 and table2 with matching values in the specified columns
Deletes all rows from table1 and table2 where the specified columns have matching values
Updates all rows in table1 and table2 where the specified columns have matching values
Retrieves all rows from table1 and the matching rows from table2
4.
Which SQL function is used to concatenate two or more strings?
JOIN()
CONCAT()
MERGE()
STRING()
5.
In SQL, what is the purpose of the CROSS JOIN clause?
Retrieves only unmatched rows from both tables
Combines each row from the first table with every row from the second table
Filters rows based on a condition after the GROUP BY clause
Groups rows based on a specified column
6.
What is the purpose of the SQL keyword 'GRANT OPTION'?
Allows a user to revoke specific privileges from other users
Allows a user to grant specific privileges to other users
Allows a user to create new tables in the database
Allows a user to drop existing tables in the database
7.
Which SQL statement is used to remove a foreign key constraint from a column?
ALTER TABLE table_name DROP FOREIGN KEY fk_constraint_name;
DROP CONSTRAINT FOREIGN KEY fk_constraint_name FROM table_name;
REMOVE FOREIGN KEY fk_constraint_name FROM table_name;
ERASE FOREIGN KEY fk_constraint_name FROM table_name;
8.
What is the purpose of the SQL keyword 'SET' in an UPDATE statement?
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
Assigns a new value to a column in an UPDATE statement
9.
Which SQL function is used to find the length of a text or varchar column excluding trailing spaces?
LEN()
CHAR_LENGTH()
LENGTH()
TRIM()
10.
What does the term 'Normalization' refer to in the context of databases?
Organizing data in a database to reduce redundancy and improve data integrity
Sorting data in ascending order
Filtering data based on a condition
Grouping data based on a column
11.
Which SQL statement is used to create a new database?
MAKE DATABASE database_name;
NEW DATABASE database_name;
ADD DATABASE database_name;
CREATE DATABASE database_name;
12.
In SQL, what is the purpose of the ROW_NUMBER() window function?
Counts the total number of rows in a table
Calculates the average value of a numeric column
Assigns a unique number to each row within a partition
Concatenates the values of a column for each group
13.
What is the purpose of the SQL keyword 'CHECK' in a CREATE TABLE statement?
Orders the result set in ascending or descending order
Filters rows based on a condition after the GROUP BY clause
Specifies a condition that must be true for each row in a table
Performs arithmetic operations on the result set
14.
Which SQL function is used to find the minimum value in a column excluding NULL values?
SMALLEST()
MIN()
LEAST()
MIN_IGNORE_NULL()
15.
What is the purpose of the SQL keyword 'MERGE' in a DELETE statement?
Specifies the criteria for deleting rows in a DELETE statement
Combines rows from two or more tables based on a related column
Performs a conditional delete based on matching rows from another table
Orders the result set in ascending or descending order
16.
Which SQL statement is used to add a unique constraint to multiple columns in an existing table?
CREATE UNIQUE CONSTRAINT unique_constraint_name ON table_name(column1, column2);
ADD CONSTRAINT unique_constraint_name UNIQUE (column1, column2) TO table_name;
ALTER TABLE table_name ADD CONSTRAINT unique_constraint_name UNIQUE (column1, column2);
ADD UNIQUE CONSTRAINT unique_constraint_name TO column1, column2 ON table_name;
17.
What does the term 'Index Scan' mean in the context of SQL query optimization?
A method of reading the entire table to find the requested data
A method of searching for data by directly accessing the data pages
A method of scanning an index to find the requested data
A method of sorting the result set
18.
Which SQL statement is used to insert data into a table by selecting values from another table?
INSERT INTO table1 VALUES (SELECT * FROM table2);
INSERT INTO table1 SELECT * FROM table2;
INSERT VALUES INTO table1 FROM table2;
INSERT table1 FROM table2 SELECT *;
19.
In SQL, what does the term 'Full Outer Join' mean?
Combines rows from two tables only if there is a match
Returns only unmatched rows from both tables
Returns all rows when there is a match in either the left or right table
Combines rows from two tables based on a related column
20.
What is the purpose of the SQL keyword 'IDENTITY' in a CREATE TABLE statement?
Specifies a condition for inserting rows into a table
Specifies the data type of a column
Defines a primary key constraint for a column
Automatically generates a unique value for a column