Connor and Chris will both be at AI World from October 12 to October 17 , the premier Oracle conference of 2025. If you're in Vegas, please come say Hi or pop into our sessions
Thanks for the question, Pablo.
Asked: November 19, 2015 - 11:14 am UTC
Last updated: February 25, 2020 - 8:41 am UTC
Version: 10R2
Viewed 1000+ times
create trigger milenio_central_logon after logon on milenio_central.schema begin execute immediate 'alter session set NLS_COMP=LINGUISTIC'; execute immediate 'alter session set NLS_SORT=XSPANISH_AI'; execute immediate 'alter session set NLS_LENGTH_SEMANTICS=CHAR'; end;
create index ix_usuarios_selector on com_usuarios(nlssort(selector,'NLS_SORT=XSPANISH_AI'));
SQL> drop table T purge; Table dropped. SQL> SQL> create table T as select * from dba_Objects; Table created. SQL> SQL> create index IX on T ( nlssort(object_name,'NLS_SORT=BINARY_CI')); Index created. SQL> SQL> begin 2 execute immediate 'alter session set NLS_COMP=LINGUISTIC'; 3 execute immediate 'alter session set NLS_SORT=BINARY_CI'; 4 execute immediate 'alter session set NLS_LENGTH_SEMANTICS=CHAR'; 5 end; 6 / PL/SQL procedure successfully completed. SQL> SQL> set autotrace on explain SQL> SQL> select count(owner) 2 from T 3 where object_name = 'ABC'; COUNT(OWNER) ------------ 1 Execution Plan ---------------------------------------------------------- Plan hash value: 2143077847 --------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 115 | 194 (0)| 00:00:01 | | 1 | SORT AGGREGATE | | 1 | 115 | | | | 2 | TABLE ACCESS BY INDEX ROWID BATCHED| T | 913 | 102K| 194 (0)| 00:00:01 | |* 3 | INDEX RANGE SCAN | IX | 365 | | 3 (0)| 00:00:01 | --------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 3 - access(NLSSORT("OBJECT_NAME",'nls_sort=''BINARY_CI''')=HEXTORAW('61626300')) SQL> SQL> select count(owner) 2 from T 3 where object_name = 'abc'; COUNT(OWNER) ------------ 1 Execution Plan ---------------------------------------------------------- Plan hash value: 2143077847 --------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 115 | 194 (0)| 00:00:01 | | 1 | SORT AGGREGATE | | 1 | 115 | | | | 2 | TABLE ACCESS BY INDEX ROWID BATCHED| T | 913 | 102K| 194 (0)| 00:00:01 | |* 3 | INDEX RANGE SCAN | IX | 365 | | 3 (0)| 00:00:01 | --------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 3 - access(NLSSORT("OBJECT_NAME",'nls_sort=''BINARY_CI''')=HEXTORAW('61626300')) SQL> SQL> select count(owner) 2 from T 3 where object_name = 'abc' 4 and ora_hash(object_name) = ora_hash('abc'); COUNT(OWNER) ------------ 0 Execution Plan ---------------------------------------------------------- Plan hash value: 2143077847 --------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 115 | 194 (0)| 00:00:01 | | 1 | SORT AGGREGATE | | 1 | 115 | | | |* 2 | TABLE ACCESS BY INDEX ROWID BATCHED| T | 9 | 1035 | 194 (0)| 00:00:01 | |* 3 | INDEX RANGE SCAN | IX | 365 | | 3 (0)| 00:00:01 | --------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - filter(ORA_HASH("OBJECT_NAME")=1194017796) 3 - access(NLSSORT("OBJECT_NAME",'nls_sort=''BINARY_CI''')=HEXTORAW('61626300')) SQL> SQL>
Duncan Gardner, February 25, 2020 - 6:49 am UTC
Check out more PL/SQL tutorials on our LiveSQL tool.
PL/SQL reference manual from the Oracle documentation library