1.
How can we get the number of records or rows in a table?
Correct Answer
A. Using COUNT
Explanation
To get the number of records or rows in a table, we can use the COUNT function. This function allows us to count the number of rows that meet a specific condition or count all the rows in the table if no condition is specified. Therefore, the correct answer is "Using COUNT" because it is the appropriate method to obtain the desired result.
2.
Which of the following ways below are the correct way to get the current date?
Correct Answer
B. SELECT CURDATE();
Explanation
The correct SQL command to retrieve the current date is SELECT CURDATE();. Option A, CURTIME(), retrieves the current time, not the date. Option C is incorrect due to a typo ("CURRRENT_TIME" should be "CURRENT_TIME()"), which retrieves the current time as well. Therefore, the only correct option for getting the current date is SELECT CURDATE();.
3.
In a LIKE clause, you can could ask for any value ending in “ton” by writing
Correct Answer
C. LIKE %ton
Explanation
The correct answer is "LIKE %ton". This is because the "%" symbol is used as a wildcard character in SQL, representing any number of characters. So when we write "LIKE %ton", it means we are looking for any value that ends with "ton".
4.
Which of these commands will delete a table called XXX if you have appropriate authority
Correct Answer
D. DROP TABLE XXX
Explanation
The correct answer is "DROP TABLE XXX". This command is used to delete a table called XXX if the user has appropriate authority. The "DROP" keyword is used to remove an entire table from the database, and "TABLE" specifies that it is a table that should be dropped. The other options either have incorrect syntax or do not specify that a table should be dropped.
5.
Which of the following is NOT available in MySQL:
Correct Answer
B. FETCH
6.
Which command is used to set the current database to “mysql”?
Correct Answer
C. USE mysql
Explanation
The correct answer is "USE mysql". This command is used to set the current database to "mysql". It is used to switch to a different database in order to perform operations on that specific database.
7.
Which of the following is not a comment in MySQL
Correct Answer
C. /# This code is commented
Explanation
The given answer, "/# This code is commented," is not a valid comment in MySQL. In MySQL, comments can be made using the following formats: "/* This code is commented */", "# This code is commented", and "-- This code is commented". However, "/# This code is commented" is not a recognized comment format in MySQL.
8.
Which join refers to join records from the right table that have no matching key in the left table are include in the result set:
Correct Answer
B. Right outer join
Explanation
A right outer join refers to joining records from the right table that have no matching key in the left table and includes them in the result set. In other words, all the records from the right table are included in the result, and if there is no match in the left table, NULL values are used for the columns of the left table in the result set.
9.
Which operation are allowed in a join view
Correct Answer
D. All of the mentioned
Explanation
In a join view, all of the mentioned operations (UPDATE, INSERT, DELETE) are allowed. This means that you can update, insert, and delete records in a join view. This allows for more flexibility and control over the data in the view, as you can make changes to the underlying tables through the join view.
10.
Which of the following is not a class of constraint in SQL Server?
Correct Answer
C. NULL
Explanation
The correct answer is NULL. In SQL Server, NULL is not a class of constraint. The NOT NULL constraint ensures that a column cannot have a NULL value, the CHECK constraint specifies a condition that must be true for each row, and the UNIQUE constraint ensures that all values in a column are unique. However, NULL itself is not a constraint class, but rather a value that represents the absence of data.
11.
Constraints can be applied on ___________
Correct Answer
D. All of the mentioned
Explanation
Constraints can be applied on columns, tables, and fields in a database. Constraints are used to enforce rules and restrictions on the data that is stored in the database. By applying constraints, we can ensure data integrity and maintain consistency in the database. Therefore, all of the mentioned options (columns, tables, and fields) can have constraints applied to them.
12.
Purpose of foreign key constraint in SQL Server is __________
Correct Answer
A. FOREIGN KEY constraints identify and enforce the relationships between tables
Explanation
The purpose of a foreign key constraint in SQL Server is to identify and enforce the relationships between tables. This means that a foreign key in one table points to a candidate key in another table, establishing a connection between the two tables. This constraint ensures that you cannot insert a row with a foreign key value unless there is a corresponding candidate key with that value.
13.
. Which of the constraint can be enforced one per table?
Correct Answer
A. Primary key constraint
Explanation
The primary key constraint can be enforced one per table. This constraint ensures that each row in a table has a unique identifier, which is the primary key. It prevents duplicate values from being inserted into the primary key column and helps maintain data integrity. Additionally, the primary key constraint also automatically creates an index on the primary key column, which improves query performance.
14.
Which of the following SQL clauses is used to filter rows after an aggregation in a MySQL query?
Correct Answer
B. HAVING
Explanation
The HAVING clause is used to filter rows after an aggregation in a MySQL query. While the WHERE clause is used to filter rows before any aggregation occurs, HAVING is specifically used after the GROUP BY clause to filter groups based on the aggregate values. The GROUP BY clause groups rows, and ORDER BY is used to sort the result set.