The following directly establishes a function based index to see if the query can use the index we established
Sql> CREATE INDEX DEPT_ID5 on dept (substr (dname,1,5));
CREATE INDEX DEPT_ID5 on dept (substr (dname,1,5))
*
ERROR is on line 1th:
ORA-01031: Insufficient Permissions
Time used: 00:00:00.00
Sql> set Autotrace off
Sql> Col username format A10
sql> Col Privilege Format A20
Sql> select Username,privilege from User_sys_privs;
USERNAME privilege
---------- --------------------
DEMO Unlimited Tablespace
Public SELECT any TABLE
Time used: 00:00:00.00
Sql> Select Username, granted_role from User_role_privs;
USERNAME Granted_role
---------- ------------------------------
DEMO CONNECT
DEMO RESOURCE
Public Plustrace
Time used: 00:00:00.01
We see that although the user has the Connect and resource roles, there is still no permission to establish the function index.
We use SYSDBA identity login, to the demo user to grant create any index and global query rewrite permissions:
Sql> Conn Lunar/lunar@test1 as Sysdba
is connected.
Sql> Grant Create any index to demo;
The authorization was successful.
Time used: 00:00:00.00
Sql> Grant global query rewrite to demo;
The authorization was successful.
Time used: 00:00:00.00
Sql> Conn Demo/demo@test1
is connected.
Sql> select Username,privilege from User_sys_privs;
USERNAME privilege
---------- --------------------
DEMO CREATE any INDEX
DEMO GLOBAL QUERY REWRITE
DEMO Unlimited Tablespace
Public SELECT any TABLE
Time used: 00:00:00.00
Sql> Select Username, granted_role from User_role_privs;
USERNAME Granted_role
---------- ------------------------------
DEMO CONNECT
DEMO RESOURCE
Public Plustrace
Time used: 00:00:00.00
Then modify the system parameters, set Query_rewrite_enabled to True, this parameter is a dynamic parameter, set can have the effect of the vertical bar to see shadow:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.