sql - Missing parenthesis error when creating Function Based Index -


I am trying to create a function based index on which there is a high cost (oracle).

I want to create an index at the column TIME_ID in the A4ORDERS table which brings the value back for the month of December:

  SELECT * to A4ORDER where TRIM (TO_CHAR (time_id , 'Month')) in December ');  

Creating FBI:

  (4) Create an index on Times (TRIM (TO_CHAR (Time_ID, 'Month') on 'A' order (' December'));  

I get a "lost right bracket" error and I can not understand why? Any guidance you provide will be appreciated

Solution from the reaction of Alex Bridge to that work:

  order a quarter (TRIM (TO_CHAR ( Time_id, 'month'));    

Build your index The statement should not contain ('December') in the section, it is only in the query if you create the index in this form:

  Create TIME_FIDX at A4ORDER ( TRIM (TO_CHAR (time_id, 'Month')); < / Code> 

... then that pointer can be used by your query:

  to choose from the Plan Spinel * where TOICH (TO_CHAR (Time_ID) , 'Month')) 'in December'); Select from the table plan_table_output (dbms_xplan.display ()); -------------------------------------------------- --------------------------------------- | ID | Operation | Name | Rows | Byte | Cost (% CPU) | Time | -------------------------------------------------- --------------------------------------- | 0 | Select Command | | 1 | 29 | 2 (0) | 00:00:01 | | 1 | Table access by INDEX ROWID. A4ORDERS | 1 | 29 | 2 (0) | 00:00:01 | | * 2 | Index Range Scan | TIME_FIDX | 1 | | 1 (0) | 00:00:01 | -------------------------------------------------- --------------------------------------- Predefined Information (Identification by Operation ID): - - ------------------------------------------------ 2 -  

Then you can see from the plan that TIME_FIDX (login) (TO_CHAR (INTERNAL_FUNCTION ("TIME_ID"), 'month')) =

Whether it is being used, it will give you an important performance advantage, can definitely be seen, and the adapter can decide that it is not selective anyway.

'Month' is NLS-sensitive though; It will either be safe to use the month's number, or specify the NLS_DATE_LANGUAGE in the TO_CHAR call, but it must be done continuously - which would be a little easier with numbers, you can also call it an indexed virtual column Can create.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -