Multiple choice technology databases

The database administrator of your company created a public synonym called HR for the HUMAN_RESOURCES table of the GENERAL schema, because many users frequently use this table. As a user of the database, you created a table called HR in your schema. What happens when you execute this query? SELECT * FROM HR;

  1. You obtain the results retrieved from the public synonym HR created by the database administrator.

  2. You obtain the results retrieved from the HR table that belongs to your schema

  3. You get an error message because you cannot retrieve from a table that has the same name as a public synonym

  4. You obtain the results retrieved from both the public synonym HR and the HR table that belongs to your schema, as a Cartesian product.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In SQL, name resolution follows a specific order: it first checks for an object in your own schema, then looks for public synonyms. Since you have a table named HR in your schema, the database will use that instead of the public synonym pointing to GENERAL.HUMAN_RESOURCES. The public synonym is only used when no object with that name exists in your schema.