Quiz 1 Set A

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Albert Christopher
A
Albert Christopher
Community Contributor
Quizzes Created: 1 | Total Attempts: 214
Questions: 18 | Attempts: 214

SettingsSettingsSettings
Quiz 1 Set A - Quiz


Questions and Answers
  • 1. 

    Construct a stored procedure, named usp_GetLastName, that accepts one input parameter named EmployeeID and returns the last name of the employee.

  • 2. 

    Create stored procedure usp_get_employees_salary_above_35000 that returns all employees’ first and last names for whose salary is above 35000. The result should be sorted by first_name then by last_name alphabetically.

  • 3. 

    A named set of SQL statements that are considered when a data modification occurs are called:

    • A.

      Stored procedures.

    • B.

      Treatments.

    • C.

      Triggers.

    • D.

      Trapdoors.

    Correct Answer
    C. Triggers.
    Explanation
    Triggers are a named set of SQL statements that are executed automatically when a specific event, such as a data modification, occurs in the database. They are used to enforce business rules, maintain data integrity, and automate certain actions. Stored procedures, on the other hand, are named sets of SQL statements that are stored in the database and can be executed on demand. Treatments and trapdoors are not relevant terms in the context of SQL.

    Rate this question:

  • 4. 

    All of the following are part of the coding structure for triggers EXCEPT:

    • A.

      A) event.

    • B.

      B) condition.

    • C.

      C) selection.

    • D.

      D) action.

    Correct Answer
    C. C) selection.
    Explanation
    Triggers in coding are used to automatically perform certain actions when a specific event occurs. The coding structure for triggers typically includes four components: event, condition, action, and selection. The event specifies the trigger point or the event that triggers the action. The condition specifies the criteria that must be met for the trigger to activate. The action specifies the specific task or action that is performed when the trigger is activated. However, selection is not a part of the coding structure for triggers, so the correct answer is C) selection.

    Rate this question:

  • 5. 

    While triggers run automatically, ________ do not and have to be called.

    • A.

      A) trapdoors

    • B.

      B) routines

    • C.

      C) selects

    • D.

      D) updates

    Correct Answer
    B. B) routines
    Explanation
    Routines are a set of instructions or procedures that need to be explicitly called in order to run. Unlike triggers, which are automatically executed in response to a specific event, routines require manual invocation. Therefore, routines are the correct answer to the question.

    Rate this question:

  • 6. 

    SQL-invoked routines can be:

    • A.

      A) procedures.

    • B.

      B) functions.

    • C.

      C) all of the above.

    • D.

      D) none of the above.

    Correct Answer
    C. C) all of the above.
    Explanation
    SQL-invoked routines can be both procedures and functions. Procedures are a set of SQL statements that perform a specific task and can be called multiple times. Functions, on the other hand, return a single value and can be used in SQL statements. Therefore, both procedures and functions are examples of SQL-invoked routines, making option C the correct answer.

    Rate this question:

  • 7. 

    All of the following are advantages of SQL-invoked routines EXCEPT:

    • A.

      A) flexibility.

    • B.

      B) efficiency.

    • C.

      C) sharability.

    • D.

      D) security.

    Correct Answer
    A. A) flexibility.
    Explanation
    SQL-invoked routines, such as stored procedures or functions, provide several advantages. They enhance efficiency by reducing network traffic and improving performance. They promote sharability by allowing multiple users to access and execute the same routine. They also enhance security by allowing the database administrator to control access and permissions. However, flexibility is not an advantage of SQL-invoked routines as they are predefined and cannot be easily modified or adapted to changing requirements.

    Rate this question:

  • 8. 

    A procedure is:

    • A.

      A) stored within the database.

    • B.

      B) given a unique name.

    • C.

      C) called by name.

    • D.

      D) all of the above.

    Correct Answer
    D. D) all of the above.
    Explanation
    A procedure is a set of instructions or a sequence of actions that can be stored within a database. It is given a unique name to identify it and can be called or executed by using that name. Therefore, all of the given options are correct as a procedure is stored within the database, given a unique name, and called by name.

    Rate this question:

  • 9. 

    Constraints are a special case of triggers.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Constraints are a special case of triggers because both are used to enforce rules and conditions on the data in a database. However, triggers are specific actions that are automatically executed when a certain event occurs, while constraints are rules that are applied to the data to ensure its integrity and consistency. Therefore, it can be said that constraints are a subset or a special case of triggers, as they are a type of rule that can be enforced through triggers.

    Rate this question:

  • 10. 

    Triggers can be used to ensure referential integrity, enforce business rules, create audit trails and replicate tables, but cannot call other triggers.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    Triggers can indeed be used to ensure referential integrity, enforce business rules, create audit trails, and replicate tables. However, triggers can also call other triggers. Therefore, the given statement that triggers cannot call other triggers is incorrect.

    Rate this question:

  • 11. 

    Triggers have three parts: the event, the condition, and the action.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    This statement is true because triggers in programming typically consist of three components: the event, which is the specific action or occurrence that initiates the trigger; the condition, which is a set of criteria that must be met for the trigger to activate; and the action, which is the specific task or set of tasks that the trigger performs when it is activated. These three parts work together to create a trigger that responds to specific events and conditions in a program.

    Rate this question:

  • 12. 

    A function has only input parameters but can return multiple values.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    A function can have both input parameters and return a single value or no value at all. However, it cannot directly return multiple values. To return multiple values, we can use data structures like arrays or objects, or we can use output parameters to modify the values of variables passed as arguments to the function. Therefore, the statement that a function can return multiple values is false.

    Rate this question:

  • 13. 

    A procedure is run by calling it by its name.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    This statement is true because in most programming languages, a procedure or function is executed by calling it by its name. The name of the procedure is used as a reference to locate and execute the code within the procedure. By calling the procedure, the program transfers control to the code inside the procedure and executes it.

    Rate this question:

  • 14. 

    The views are created by executing a CREATE VIEW SQL command.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Views in a database are created by executing a CREATE VIEW SQL command. This command allows users to create a virtual table that is based on the result of a query. The view can then be used to retrieve data from multiple tables or to simplify complex queries. By creating views, users can easily access and manipulate data without needing to write complex queries each time. Therefore, the statement that views are created by executing a CREATE VIEW SQL command is true.

    Rate this question:

  • 15. 

    The variables in the triggers are declared using

    • A.

      A) –

    • B.

      B) @

    • C.

      C) /

    • D.

      D) /@

    Correct Answer
    B. B) @
    Explanation
    In many programming languages and systems, including databases and event-driven systems, the "@" symbol is commonly used to declare variables in triggers. This symbol is used to differentiate variables from other elements in the code and to indicate that a specific value will be assigned to the variable. Therefore, the correct answer is b) @.

    Rate this question:

  • 16. 

    John creates a trigger on the Sales table. He is trying to enforce the business rule that no order can be created (inserted) with a total less than $20. However, it can be updated by a supervisor, if necessary. What must his code do to the Sales table if the test inside the trigger tries to insert an order with a total of $15? Please select the best answer.  

    • A.

      A.    Delete the row from the Inserted table.

    • B.

      B.    Delete the row from the Sales table.

    • C.

      C.    Do nothing; the trigger will do it automatically.

    • D.

      D.    Delete the row from both the Inserted and the Sales tables.

    Correct Answer
    B. B.    Delete the row from the Sales table.
    Explanation
    The correct answer is B.

    He needs to delete the data from the Sales table if the rule fails. A is incorrect because the Inserted table can never have any action performed on it other than a SELECT statement. C is incorrect because the trigger cannot know what to do if John doesn’t code for it. D is incorrect because, again, the Inserted table can only have data selected from it.

    Rate this question:

  • 17. 

    If you insert data into the Category table that has an INSERT trigger on it, what happens to the data when the trigger fires? Please select the best answer.      

    • A.

      A.    The data resides in the Inserted and the Category tables.

    • B.

       B.    The data resides in only the Inserted table.

    • C.

      C.    The data resides in only the Category table.

    • D.

       D.    The data resides in the Inserted and Deleted tables.

    Correct Answer
    A. A.    The data resides in the Inserted and the Category tables.
    Explanation
    A is correct.

    The data resides in the Inserted and the Category tables. B is incorrect because the data also resides in the Category table. C is incorrect because the data also resides in the Inserted table. D is incorrect because only UPDATE triggers affect both the Inserted and Deleted tables.

    Rate this question:

  • 18. 

    What makes stored procedures faster than sending a Transact-SQL statement to SQL Server? Please select the best answer.

    • A.

           A.    They are not faster.

    • B.

           B.    The query plan is compiled and cached on the server.

    • C.

           C.    The Transact-SQL statements are shorter.

    • D.

          D.    There are less commands available, so parsing time is shorter.

    Correct Answer
    B.      B.    The query plan is compiled and cached on the server.
    Explanation
    The correct answer is B.

    A stored procedure is compiled and its query plan is cached. A is incorrect because stored procedures are faster. C is incorrect because Transact-SQL statements do not have to be shorter in stored procedures. D is incorrect because the same number of commands are available to both.

    Rate this question:

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.