1.
You can fetch only one row at a time.
Correct Answer
B. False
Explanation
The fetch command moves the current cursor position one or more rows down the cursor result set. By default, a fetch returns only a single row.
The syntax for multiple rows: set cursor rows number for cursor_name
2.
A stored procedure or trigger can define two cursors with the same name if only one is executed.
Correct Answer
A. True
Explanation
For example, the following stored procedure works, because only one emp_crsr cursor is defined in its scope:
create procedure sp_emp_proc @id int
as
if @id > 100
declare emp_crsr cursor
for select fname from employee
else
declare emp_crsr cursor
for select lname from employee
return
3.
If @@sqlstatus = 1, then:
Correct Answer
B. Indicates that the fetch statement resulted in an error.
Explanation
If @@sqlstatus = 1, it indicates that the fetch statement resulted in an error. This means that there was an issue with retrieving data from the result set.
4.
If @@sqlstatus = 2, then:
Correct Answer
C. Indicates that there is no more data in the result set.
Explanation
If @@sqlstatus = 2, it indicates that there is no more data in the result set. This means that the fetch statement has successfully retrieved all the available data and there are no more rows to fetch.
5.
If @@sqlstatus = 0, then:
Correct Answer
A. Indicates successful completion of the fetch statement.
Explanation
The correct answer is "Indicates successful completion of the fetch statement." This means that if the value of @@sqlstatus is 0, it indicates that the fetch statement was executed successfully and there is no error.
6.
Which of the following statements is TRUE for the having clause
A) aggregates are permitted in the having clause
B) subqueries are permitted in the having clause
Correct Answer
C. Both A and B
Explanation
The correct answer is Both A and B. The having clause in SQL allows the use of aggregates, such as SUM or COUNT, to filter the results of a query based on a condition. It also permits the use of subqueries, which are queries nested within the main query, to further filter the results. Therefore, both statements A and B are true for the having clause.
7.
The ________ operator combines result sets from multiple queries.
Correct Answer
D. Union all
Explanation
The "union all" operator combines the result sets from multiple queries, including duplicate rows. It concatenates the rows from all the queries and returns a single result set. This allows for the combination of data from different queries into a single result, without removing any duplicate rows.
8.
Is it possible to Enable or Disable a Database trigger ?
Correct Answer
A. True
Explanation
It is possible to enable or disable a database trigger. A trigger is a stored procedure that automatically executes when a specific event occurs in the database. By enabling or disabling a trigger, we can control whether it will execute or not when the associated event occurs. This allows us to temporarily disable a trigger without deleting it from the database, and later enable it again when needed.
9.
You can create a trigger on a temporary object.
Correct Answer
B. False
Explanation
Triggers cannot be created on temporary objects. Temporary objects are session-specific and are automatically dropped at the end of the session. Triggers are used to perform actions when certain events occur on a database table, and they require a permanent object to be associated with. Therefore, it is not possible to create a trigger on a temporary object.
10.
You can use the disable trigger feature only if you are the table owner or database administrator.
Correct Answer
A. True
Explanation
The statement is stating that the disable trigger feature can only be used by the table owner or the database administrator. This means that regular users or other roles do not have the authority to use this feature. Therefore, the correct answer is true.