John has created a procedure named SALARY_CALC. Which SQL query allows him to view the text of the procedure?

  1. SELECT text FROM user_source WHERE name ='SALARY_CALC';

  2. SELECT * FROM user_source WHERE source_name ='salary_calc';

  3. SELECT * FROM user_objects WHERE object_name = 'SALARY_CALC';

  4. SELECT text FROM user_source WHERE name='SALARY_CALC' AND owner ='JOHN';


Correct Option: A
Explanation:

To solve this question, the user needs to know the structure of the system tables in Oracle database where all the objects are stored.

Option A is correct. This query will return the text of the procedure SALARY_CALC. The user_source view contains all the source code for the stored procedures, functions, and triggers in the current user's schema. By specifying the name of the procedure in the WHERE clause, the query filters the result set to only show the source code for the SALARY_CALC procedure.

Option B is incorrect. There is no column named "source_name" in the user_source view. Therefore, this query will return an error.

Option C is incorrect. The user_objects view contains information about all objects in the current user's schema, including tables, views, indexes, and procedures. However, the view does not contain the source code for the procedures. Therefore, this query will not return any rows.

Option D is incorrect. The condition "AND owner='JOHN'" is unnecessary because the user_source view only contains source code for the objects owned by the current user. Therefore, this query will return the same result as option A, but with an unnecessary condition.

The Answer is: A. SELECT text FROM user_source WHERE name ='SALARY_CALC';

Find more quizzes: