1.
Which SQL function is used to count the number of rows in a SQL query?
Correct Answer
D. COUNT(*)
Explanation
The COUNT(*) function is used to count the number of rows in a SQL query. It returns the number of rows that match the specified condition or criteria in the query. The asterisk (*) in COUNT(*) is a wildcard that represents all columns in the table, so it counts all rows regardless of the values in any specific column. This function is commonly used to obtain the total number of records in a table or to count the number of rows that meet certain criteria.
2.
Which SQL keyword is used to retrieve a maximum value?
Correct Answer
C. MAX
Explanation
The keyword "MAX" is used in SQL to retrieve the maximum value from a specified column. It is commonly used in conjunction with the SELECT statement and the GROUP BY clause to find the highest value in a specific column or set of columns.
3.
Which of the following SQL clauses is used to DELETE tuples from a database table?
Correct Answer
A. DELETE
Explanation
The DELETE clause in SQL is used to remove or delete tuples from a database table. It allows for the selective removal of specific rows based on certain conditions specified in the WHERE clause. This clause is commonly used to remove unwanted or outdated data from a table, maintaining data integrity and keeping the database clean and organized.
4.
If you don’t specify ASC or DESC after a SQL ORDER BY clause, the following is used by default __________
Correct Answer
A. ASC
Explanation
If you don't specify ASC or DESC after a SQL ORDER BY clause, the default is ASC. ASC stands for "ascending" and it arranges the data in ascending order, meaning from the smallest value to the largest value.
5.
Which of the following function is an aggregate function?
Correct Answer
D. Max
Explanation
Max is an aggregate function because it is used to find the maximum value in a set of values. It is commonly used in SQL queries to retrieve the maximum value from a specific column in a table. The Max function takes multiple values as input and returns the largest value among them. It is often used in conjunction with the Group By clause to find the maximum value for each group in a result set.
6.
Which statement is wrong about PRIMARY KEY constraint in SQL?
Correct Answer
C. Primary key must be made of any single columns
Explanation
The statement that is wrong about the PRIMARY KEY constraint in SQL is "Primary key must be made of any single columns". This is incorrect because a primary key can be made based on multiple columns.
7.
In existing table, ALTER TABLE statement is used to
Correct Answer
E. All of the above
Explanation
The ALTER TABLE statement in SQL is used to modify an existing table. It can be used to add columns to the table, add constraints to the table, delete columns from the table, and delete constraints from the table. Therefore, the correct answer is "All of the above" as the ALTER TABLE statement can perform all of these actions on an existing table.
8.
Wrong statement about UPDATE keyword is
Correct Answer
B. Only one record can be updated at a time using WHERE clause
Explanation
The correct answer is "Only one record can be updated at a time using WHERE clause." This is because the WHERE clause is used to specify the condition that must be met for the update to occur. If the WHERE clause is missing, the update statement will update all records in the table. However, if the WHERE clause is present and specifies a condition, only the record(s) that meet that condition will be updated. Therefore, multiple records can be updated at a time using the WHERE clause, but each update will only affect one record.
9.
Wrong statement about ORDER BY keyword is
Correct Answer
D. To sort the records in descending order, use the DECENDING keyword.
10.
In a table, a column contains a duplicate value, if you want to list all different value only, then which SQL clause is used?
Correct Answer
A. SQL DISTINCT
Explanation
The SQL DISTINCT clause is used to retrieve only unique values from a column in a table. It eliminates any duplicate values and returns a result set with only distinct values. Therefore, if you want to list all different values from a column that contains duplicates, you would use the SQL DISTINCT clause.