The following error is found when dbms_xplan.display_cursor function is used. SQL> select * from table (dbms_xplan.display_cursor); plan_table_output using user has no select privilege on V $ sessionsql> view the following statements on the official website: this package runs with the privileges of the calling user, not the package owner (sys ). the table functiondisplay_cursor requires to have select privileges on the following fixed views: V $ SQL _plan, V $ Session and V $ SQL _plan_statistics_all. That is to say, you must have the permissions v $ SQL _plan, V $ session, and V $ SQL _plan_statistics_all. SQL> conn sys/root as sysdbaconnected. SQL> grant select on V _ $ SQL _plan to Rhys; grant succeeded. SQL> grant select on V _ $ session to Rhys; grant succeeded. SQL> grant select on V _ $ SQL _plan_statistics_all to Rhys; grant succeeded. SQL> conn Rhys/amyconnected. SQL> select * from table (dbms_xplan.display_cursor); plan_table_output ---------------------------------------------------------------------------- --------------------------------------------------------------------- User has no select privilege on V $ sessionsql> still has an error. Why? Then I read the online manual and found the following sentence: to use the display_cursor functionality, the calling user must haveselect privilege on the fixed views v $ SQL _plan_statistics_all, V $ SQL and V $ SQL _plan, otherwise it shows an appropriate error message. haha. This makes it clear that to use display_cursor, you must have permissions for the four views v $ SQL, V $ SQL _plan_statistics_all, V $ session, and V $ SQL _pan. Let's take a look at the permissions of the Rhys account: SQL> conn sys/root as sysdbaconnected. SQL> grant select on V _ $ SQL to Rhys; grant succeeded. SQL> conn Rhys/amyconnected. SQL> select * from table (dbms_xplan.display_cursor); dyk4dprp70d74, child number 0 ------------------------------------- select decode ('A ', 'A', '1', '2') from dual plan hash value: 1388734953 ------------------------------------------------------------- | ID | operation | Name | rows | cost (% CPU) | time | --------------------------------------------------------------- | 0 | SELECT statement | 2 (100) | 1 | fast dual | 1 | 2 (0) | 00:00:01 | ------------------------------------------------------------------- plan_table_output limit 13 rows selected. SQL>
Convert user has no select privilege on V $ session