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
D. All of the above
Explanation
All of the given options are correct ways to get the current date.
- SELECT CURTIME() will return the current time in the format HH:MM:SS.
- SELECT CURDATE() will return the current date in the format YYYY-MM-DD.
- SELECT CURRENT_TIME() will return the current time in the format HH:MM:SS.
Therefore, all three options can be used to retrieve the current date or time depending on the requirement.
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.
Difference between a primary key and a unique key?
Correct Answer
C. You can have only one primary key whereas you can have multiple unique keys
Explanation
The correct answer is that you can have only one primary key whereas you can have multiple unique keys. This is because a primary key is used to uniquely identify each record in a table and enforce entity integrity, while a unique key is used to ensure that each value in a column is unique. Therefore, a table can only have one primary key, but it can have multiple unique keys to enforce different uniqueness constraints on different columns.