SCOTT user has grants on HR schema objects. You are connected to SCOTT schema and issued following command:Create synonym emp for hr.employees;What happens when you issue this statement?

  1. An error is generated.

  2. A public synonym is created for employees table.

  3. You create an alternative name for the employees table of HR schema in HR schema

  4. You create an alternative name for the employees table of HR schema in SCOTT schema


Correct Option: D

AI Explanation

To answer this question, you need to understand the concept of synonyms in Oracle databases.

A synonym is an alternative name for a database object, such as a table, view, sequence, or procedure. It allows you to access the object using a different name, providing a level of abstraction and simplifying the way you refer to the object.

In this scenario, the statement "CREATE SYNONYM emp FOR hr.employees;" is issued while connected to the SCOTT schema. Let's go through each option to understand why it is correct or incorrect:

Option A) An error is generated - This option is incorrect. The statement is syntactically correct, so it will not generate an error.

Option B) A public synonym is created for the employees table - This option is incorrect. The statement does not specify the "PUBLIC" keyword, so it creates a private synonym, not a public synonym.

Option C) You create an alternative name for the employees table of HR schema in HR schema - This option is incorrect. The synonym is created in the SCOTT schema, not the HR schema.

Option D) You create an alternative name for the employees table of HR schema in SCOTT schema - This option is correct. The statement creates a synonym named "emp" in the SCOTT schema, which refers to the "employees" table in the HR schema. This allows you to refer to the "employees" table using the "emp" synonym in the SCOTT schema.

Therefore, the correct answer is D. You create an alternative name for the employees table of HR schema in the SCOTT schema.

Find more quizzes: