0

databases Online Quiz - 34

Description: databases Online Quiz - 34
Number of Questions: 20
Created by:
Tags: databases
Attempted 0/20 Correct 0 Score 0

Transaction ends

  1. Only when it is Committed

  2. Only when it is Rolledback

  3. When it is Committed or Rolledback

  4. None of the above


Correct Option: C

What SYSTEM VARIABLE is used to refer DATABASE TIME ?

  1. $$dbtime$$

  2. $$time$$

  3. $$datetime$$

  4. None of the above


Correct Option: A

Which of the following is not correct about a View ?

  1. To protect some of the columns of a table from other users

  2. Ocuupies data storage space

  3. To hide complexity of a query

  4. To hide complexity of a calculations


Correct Option: B

AI Explanation

To answer this question, you need to understand the concept of a View. Let's go through each option to understand why it is correct or incorrect:

Option A) To protect some of the columns of a table from other users - This option is correct. A View can be used to restrict access to certain columns of a table, allowing only authorized users to view those columns.

Option B) Occupies data storage space - This option is incorrect. A View does not occupy data storage space because it is a virtual table that is derived from the underlying base table. It does not store any data itself.

Option C) To hide complexity of a query - This option is correct. A View can be used to simplify complex queries by creating a virtual table that represents a subset of the data from one or more tables. This allows users to interact with the View instead of directly querying the underlying tables.

Option D) To hide complexity of calculations - This option is correct. A View can be used to encapsulate complex calculations or transformations, making it easier for users to access the results of those calculations without needing to understand the underlying logic.

The correct answer is B) Occupies data storage space. This option is incorrect because a View does not occupy data storage space.

CREATE OR REPLACE FUNCTION CALC_PLAYER_AVG (V_ID in PLAYER_BAT_STAT.PLAYER_ID%TYPE) RETURN NUMBER IS V_AVG NUMBER; BEGIN SELECT HITS / AT_BATS INTO V_AVG FROM PLAYER_BAT_STAT WHERE PLAYER_ID = V_ID; RETURN (V_AVG); END; Which statement will successfully invoke this function in SQL *Plus

  1. SELECT CALC_PLAYER_AVG(PLAYER_ID) FROM PLAYER_BAT_STAT;

  2. EXECUTE CALC_PLAYER_AVG(31);

  3. CALC_PLAYER(‘RUTH’);

  4. CALC_PLAYER_AVG(31);


Correct Option: A

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) SELECT CALC_PLAYER_AVG(PLAYER_ID) FROM PLAYER_BAT_STAT; This option is correct because it correctly invokes the function CALC_PLAYER_AVG by passing the PLAYER_ID column from the PLAYER_BAT_STAT table as the argument.

Option B) EXECUTE CALC_PLAYER_AVG(31); This option is incorrect because the EXECUTE statement is not supported in SQL *Plus. Instead, you should use a SELECT statement to invoke the function.

Option C) CALC_PLAYER('RUTH'); This option is incorrect because it does not match the function name. The correct function name is CALC_PLAYER_AVG.

Option D) CALC_PLAYER_AVG(31); This option is incorrect because it does not include the necessary SELECT statement to invoke the function. The correct syntax is to use a SELECT statement as shown in option A.

The correct answer is A. This option is correct because it uses the correct function name and syntax to invoke the function CALC_PLAYER_AVG.

Which is the true statements about dependent objects?

  1. An object with status of invalid cannot be a referenced object.

  2. The Oracle server automatically records dependencies among objects.

  3. All schema objects have a status that is recorded in the data dictionary.

  4. You can view whether an object is valid or invalid in the USER_STATUS data dictionary view.


Correct Option: B

You have created a stored procedure DELETE_TEMP_TABLE that uses dynamic SQL to remove a table in your schema. You have granted the EXECUTE privilege to user A on this procedure. When user A executes the DELETE_TEMP_TABLE procedure, under whose privileges are the operations performed by default?

  1. SYS privileges

  2. Your privileges

  3. Public privileges

  4. User A’s privileges


Correct Option: B

CREATE OR REPLACE PRODECURE add_dept (p_dept_name VARCHAR2 DEFAULT ‘placeholder’, p_location VARCHAR2 DEFAULT ‘Boston’) IS BEGIN INSERT INTO departments VALUES (dept_id_seq.NEXTVAL, p_dept_name, p_location); END add_dept; / Which is invalid call to the add_dep procedure? (Choose three

  1. add_dept;

  2. add_dept(‘Accounting’);

  3. add_dept(, ‘New York’);

  4. add_dept(p_location=>’New York’);


Correct Option: C

Which programming constructs can be grouped within a package?

  1. Cursor

  2. Trigger

  3. Sequence

  4. View


Correct Option: A

AI Explanation

To answer this question, we need to understand the concept of a package in programming.

A package is a way to group related programming constructs together. It helps in organizing and managing code by providing a logical structure. In most programming languages, packages are used to group similar functions, classes, variables, or other constructs.

Let's go through each option to determine which programming constructs can be grouped within a package:

A) Cursor - A cursor is not a programming construct that can be grouped within a package. It is used to traverse or manipulate the result set returned by a database query. Therefore, option A is incorrect.

B) Trigger - A trigger is a database object that is associated with a table and is activated when a specific event occurs (e.g., when a row is inserted, updated, or deleted). Triggers are not programming constructs that can be grouped within a package. Therefore, option B is incorrect.

C) Sequence - A sequence is a database object that generates a sequence of unique numbers. Similar to triggers and cursors, sequences are not programming constructs that can be grouped within a package. Therefore, option C is incorrect.

D) View - A view is a database object that is derived from one or more tables or other views. It is like a virtual table that provides a way to present data in a predefined manner. Views are not programming constructs that can be grouped within a package. Therefore, option D is incorrect.

The correct answer is A) Cursor. Cursors are programming constructs that can be grouped within a package. They are used to retrieve and manipulate data from a database query result set. By grouping cursors within a package, you can organize and manage database operations efficiently.

Therefore, the correct answer is A) Cursor.

Which statement describe the state of a package variable after executing the package in which it is declared?

  1. It persists across transactions within a session.

  2. It persists from session to session for the same user.

  3. It does not persist across transaction within a session.

  4. It persists from user to user when the package is invoked.


Correct Option: A
Explanation:

To answer this question, the user needs to understand the concept of package variables in PL/SQL.

Package variables are variables that are declared in the package specification and can be accessed by any subprogram or procedure defined in the package. The state of a package variable after executing the package depends on its type.

Option A is correct. Package variables persist across transactions within a session. This means that the value of a package variable remains the same during the lifetime of the session, even if multiple transactions are executed. The value of the variable can be changed by any subprogram or procedure defined in the package.

Option B is incorrect. Package variables do not persist from session to session for the same user. When a user logs out of the session and logs back in, the package variable is reinitialized with its default value.

Option C is incorrect. Package variables persist across transactions within a session. The value of a package variable remains the same during the lifetime of the session, even if multiple transactions are executed.

Option D is incorrect. Package variables do not persist from user to user when the package is invoked. When a different user invokes the package, the package variable is reinitialized with its default value.

Therefore, the correct answer is:

The Answer is: A

Which statement is valid when removing procedures?

  1. Use a drop procedure statement to drop a standalone procedure.

  2. Use a drop procedure statement to drop a procedure that is part of a package. Then recompile the package specification.

  3. Use a drop procedure statement to drop a procedure that is part of a package. Then recompile the package body.

  4. For faster removal and re-creation, do not use a drop procedure statement. Instead, recompile the procedure using the alter procedure statement with the REUSE SETTINGS clause.


Correct Option: A

AI Explanation

To answer this question, you need to understand the process of removing procedures in a database.

Let's go through each option to understand why it is correct or incorrect:

Option A) Use a drop procedure statement to drop a standalone procedure. - This option is correct because when removing a standalone procedure, you can use the "DROP PROCEDURE" statement to remove it from the database.

Option B) Use a drop procedure statement to drop a procedure that is part of a package. Then recompile the package specification. - This option is incorrect because when removing a procedure that is part of a package, you need to drop the package, not just the procedure. Additionally, after dropping the package, you would need to recompile both the package specification and the package body.

Option C) Use a drop procedure statement to drop a procedure that is part of a package. Then recompile the package body. - This option is incorrect for the same reasons mentioned in Option B. When removing a procedure that is part of a package, you need to drop the entire package, and then recompile both the package specification and the package body.

Option D) For faster removal and re-creation, do not use a drop procedure statement. Instead, recompile the procedure using the alter procedure statement with the REUSE SETTINGS clause. - This option is incorrect because using the "ALTER PROCEDURE" statement with the "REUSE SETTINGS" clause does not remove the procedure from the database. It only recompiles the procedure with the existing settings.

The correct answer is A) Use a drop procedure statement to drop a standalone procedure. This option is correct because when removing a standalone procedure, you can use the "DROP PROCEDURE" statement to remove it from the database.

Which statement is false?

  1. If errors occur during the compilation of a trigger, the trigger is still created.

  2. If errors occur during the compilation of a trigger you can go into SQL *Plus and query the USER_TRIGGERS data dictionary view to see the compilation errors.

  3. If errors occur during the compilation of a trigger you can use the SHOW ERRORS command within iSQL *Plus to see the compilation errors.

  4. If errors occur during the compilation of a trigger you can go into SQL *Plus and query the USER_ERRORS data dictionary view to see compilation errors.


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) If errors occur during the compilation of a trigger, the trigger is still created. This option is correct. In Oracle, even if errors occur during the compilation of a trigger, the trigger is still created. However, it may not function correctly if there are compilation errors.

Option B) If errors occur during the compilation of a trigger, you can go into SQL *Plus and query the USER_TRIGGERS data dictionary view to see the compilation errors. This option is incorrect. The USER_TRIGGERS data dictionary view does not provide information about compilation errors. It provides information about triggers, such as their names, types, and status, but not the compilation errors.

Option C) If errors occur during the compilation of a trigger, you can use the SHOW ERRORS command within iSQL *Plus to see the compilation errors. This option is correct. In Oracle, you can use the SHOW ERRORS command within iSQL *Plus to see the compilation errors for triggers. This command displays the error messages and line numbers associated with the compilation errors.

Option D) If errors occur during the compilation of a trigger, you can go into SQL *Plus and query the USER_ERRORS data dictionary view to see compilation errors. This option is correct. In Oracle, you can query the USER_ERRORS data dictionary view in SQL *Plus to see the compilation errors for triggers. This view contains information about the errors, including the line numbers and error messages.

The false statement is Option B. The USER_TRIGGERS data dictionary view does not provide information about compilation errors.

Which dictionary views track dependencies?

  1. USER_SOURCE

  2. UTL_DEPTREE

  3. USER_OBJECTS

  4. DEPTREE_TEMPTAB


Correct Option: D

AI Explanation

To answer this question, we need to understand the concept of dictionary views and dependency tracking.

Dictionary views in Oracle database provide information about various database objects and their properties. They are read-only views that are created and maintained by the database.

Dependency tracking refers to the ability to determine the dependencies between different database objects. This information is useful when performing tasks such as object recompilation or dropping an object.

Now, let's go through each option to understand which one tracks dependencies:

Option A) USER_SOURCE - This is a dictionary view that provides information about the source code of stored procedures, functions, and packages. It does not track dependencies.

Option B) UTL_DEPTREE - This is not a valid dictionary view in Oracle database. Therefore, it does not track dependencies.

Option C) USER_OBJECTS - This is a dictionary view that provides information about all objects owned by the current user. It does not track dependencies.

Option D) DEPTREE_TEMPTAB - This is the correct option. DEPTREE_TEMPTAB is a dictionary view that tracks dependencies between different database objects. It is used by the UTL_DEPTREE package to store dependency information temporarily.

Therefore, the correct answer is option D) DEPTREE_TEMPTAB. This option is correct because DEPTREE_TEMPTAB is a dictionary view that tracks dependencies between database objects.

What happens during the execute phase with dynamic SQL for INSERT, UPDATE, and DELETE operations?

  1. The rows are selected and ordered.

  2. The validity of the SQL statement is established.

  3. An area of memory is established to process the SQL statement.

  4. The SQL statement is run and the number of rows processed is returned.


Correct Option: D

What part of a database trigger determines the number of times the trigger body executes?

  1. Trigger type

  2. Trigger body

  3. Trigger event

  4. Trigger timing


Correct Option: A

AI Explanation

To answer this question, you need to understand the different components of a database trigger.

A database trigger is a stored program that automatically executes in response to an event, such as a data modification operation (insert, update, delete) performed on a specified table. The trigger consists of three main parts: the trigger event, the trigger timing, and the trigger body.

The trigger event (option C) determines when the trigger should execute, such as before or after an insert, update, or delete operation on a table.

The trigger timing (option D) determines whether the trigger executes before or after the triggering event occurs.

The trigger body (option B) contains the code or instructions that are executed when the trigger is fired.

The part of a database trigger that determines the number of times the trigger body executes is the trigger type (option A). The trigger type specifies whether the trigger is a row-level trigger or a statement-level trigger.

  • A row-level trigger executes once for each row affected by the triggering event.
  • A statement-level trigger executes once for each triggering event, regardless of the number of rows affected.

Therefore, the correct answer is option A) Trigger type. This option is correct because the trigger type determines the number of times the trigger body executes.

Which table should you query to determine when your procedure was last compiled?

  1. USER_PROCEDURES

  2. USER_PROCS

  3. USER_OBJECTS

  4. USER_PLSQL_UNITS


Correct Option: C

AI Explanation

To determine when your procedure was last compiled, you should query the USER_OBJECTS table.

Let's analyze each option to understand why the correct answer is C:

Option A) USER_PROCEDURES - This option is incorrect because the USER_PROCEDURES table does not provide information about when a procedure was last compiled. It contains information about procedures owned by the current user, but not the compilation timestamp.

Option B) USER_PROCS - This option is incorrect because there is no standard Oracle table named USER_PROCS. It is not a valid table in the Oracle database.

Option C) USER_OBJECTS - This option is correct because the USER_OBJECTS table contains information about all objects owned by the current user, including procedures. It includes a LAST_DDL_TIME column that represents the timestamp of the last DDL (Data Definition Language) operation performed on the object, which includes the compilation of a procedure.

Option D) USER_PLSQL_UNITS - This option is incorrect because the USER_PLSQL_UNITS table stores information about PL/SQL units, such as packages, functions, and procedures. However, it does not specifically provide information about when a procedure was last compiled.

The correct answer is C) USER_OBJECTS. This table should be queried to determine when your procedure was last compiled because it includes the necessary information in the LAST_DDL_TIME column.

  1. a record

  2. a field

  3. a table

  4. an entity


Correct Option: B

"A student has such attributes as name, address, and gender. A student can also attend a graduate, undergraduate, or elective class that has the following attributes: class name, section name, major, and instructor. Based on the scenario above, which is the composite key in a junction table if many students can attend many classes?

  1. section name, age

  2. name

  3. undergraduate

  4. name, class name

  5. major, gender


Correct Option: D

Which of the following is not a data modeling tool?

  1. Visio

  2. ERwin

  3. ER/Studio

  4. Data Builder

  5. empowER


Correct Option: D
  1. Design logical data systems

  2. Design physical storage system

  3. Define data entities relevant to the enterprise

  4. All of the above


Correct Option: C
  1. Business Data Model

  2. Logical Data Model

  3. Data Management Process Model

  4. Data entity/business function Matrix

  5. Data Interface requirements


Correct Option: E
- Hide questions