对于ORACLE-如何创建在NLS_COMP=语言且NLS_Sort=Binary_CI时将使用的索引感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍oracle创建synonym,并为您提供关
对于ORACLE-如何创建在NLS_COMP =语言且NLS_Sort = Binary_CI时将使用的索引感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍oracle创建synonym,并为您提供关于Insert Unicode Using cx-Oracle and Setting NLS_LANG for Oracle、mtk_gps_sys_gps_mnl_callback、mybatis操作Oracle数据库如何指定NLS_LANGUAGE多语言、Oracle NLSSORT的有用信息。
本文目录一览:- ORACLE-如何创建在NLS_COMP =语言且NLS_Sort = Binary_CI时将使用的索引(oracle创建synonym)
- Insert Unicode Using cx-Oracle and Setting NLS_LANG for Oracle
- mtk_gps_sys_gps_mnl_callback
- mybatis操作Oracle数据库如何指定NLS_LANGUAGE多语言
- Oracle NLSSORT
ORACLE-如何创建在NLS_COMP =语言且NLS_Sort = Binary_CI时将使用的索引(oracle创建synonym)
默认情况下,Oracle使用创建的索引。
当我更改为NLS_COMP =语言并且NLS_Sort = Binary_CI时,我得到了全表扫描。
我读过某处使用(nlssort(name,’NLS_SORT = BINARY_CI’))创建索引的地方; 会工作。
正如我下面的尝试所示,没有那么多。即使我强行执行,性能似乎也不是我所期望的。这是一个微不足道的示例,我想为具有数百万行的表解决此问题,因此全表扫描将很糟糕。
所以问题是如何建立索引以便使用索引。
谢谢
-设置X
create table x ( name varchar2(30)) ;insert into x select table_name from all_tables;create index x_ix on x (name);create index x_ic on x (nlssort(name, ''NLS_SORT=BINARY_CI''));/
- 默认设置
ALTER SESSION SET NLS_COMP=BINARY;ALTER SESSION SET NLS_SORT=BINARY; /set autotrace on /select * from X where NAME like ''x%'';--0 rows selected-------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |-----------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 1 | 17 | 1 (0)| 00:00:01 |--|* 1 | INDEX RANGE SCAN| X_IX | 1 | 17 | 1 (0)| 00:00:01 |---------------------------------------------------------------------------/set autotrace off/
-语言
ALTER SESSION SET NLS_COMP=LINGUISTIC; ALTER SESSION SET NLS_SORT=BINARY_CI; /set autotrace on/select * from X where NAME like ''x%'';--13 rows selected--------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 1 | 17 | 3 (0)| 00:00:01 |--|* 1 | TABLE ACCESS FULL| X | 1 | 17 | 3 (0)| 00:00:01 |----------------------------------------------------------------------------select /*+ INDEX( X X_IX ) */ * from X where NAME like ''x%'';--13 rows selected-------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |-----------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 1 | 17 | 9 (0)| 00:00:01 |--|* 1 | INDEX FULL SCAN | X_IX | 1 | 17 | 9 (0)| 00:00:01 |---------------------------------------------------------------------------select /*+ INDEX( X X_IC ) */ * from X where NAME like ''x%''; --13 rows selected------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |----------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 1 | 17 | 448 (1)| 00:00:06 |--|* 1 | TABLE ACCESS BY INDEX ROWID| X | 1 | 17 | 448 (1)| 00:00:06 |--| 2 | INDEX FULL SCAN | X_IC | 1629 | | 8 (0)| 00:00:01 |--------------------------------------------------------------------------------------/set autotrace off/
答案1
小编典典由于的Oracle 11g -像CAN使用语言索引。该文档已修改为:
The SQL functions MAX( ) and MIN( ) cannot use linguistic indexes when NLS_COMP is set to LINGUISTIC
注意,他们删除了“以及LIKE运算符”部分。
Insert Unicode Using cx-Oracle and Setting NLS_LANG for Oracle
set enviroment in python or bash
- os.environ["NLS_LANG"] = "TRADITIONAL CHINESE_HONG KONG.AL32UTF8"
or - export NLS_LANG="TRADITIONAL CHINESE_HONG KONG.AL32UTF8"
get lang in Oracle
- SELECT USERENV (''language'') FROM DUAL;
- select * from v$nls_parameters WHERE parameter IN ( ''NLS_LANGUAGE'', ''NLS_TERRITORY'', ''NLS_CHARACTERSET'');
- SELECT * from NLS_DATABASE_PARAMETERS WHERE parameter IN ( ''NLS_LANGUAGE'', ''NLS_TERRITORY'', ''NLS_CHARACTERSET'');
others
- select * FROM V$NLS_VALID_VALUES;
- select * from NLS_SESSION_PARAMETERS;
- select * from database_properties;
mtk_gps_sys_gps_mnl_callback
mtk_gps_sys_gps_mnl_callback这是什么错误啊mybatis操作Oracle数据库如何指定NLS_LANGUAGE多语言
一、背景
笔者碰到应用系统连接Oracle数据库时多语言需要统一使用英语,该配置不能在数据库Server端修改,因些需要在应用系统端想办法进行配置。
二、解决方式
经过查阅数据源和mybatis相关源码,有两种方式支持修改:
1、使用Druid数据源的配置项connectionInitSqls定义连接初始化语句:
connectionInitSqls: ["ALTER SESSION SET NLS_LANGUAGE=''AMERICAN''"]
2、不修改数据源配置,在应用系统端增加mybatis的拦截器,拦截器代码如下:
(1)、Spring boot的Bean配置
@Configuration
public class MybatisPlusConfig {
/**
* 更改会话状态
*
* @return
*/
@Bean
public AlterSessionInterceptor alterSessionInterceptor() {
return new AlterSessionInterceptor();
}
/**
* 乐观锁插件
*
* @return
*/
@Bean
public CustomOptimisticLockerInterceptor optimisticLockerInterceptor() {
return new CustomOptimisticLockerInterceptor();
}
/**
* oracle Sequence主键
*
* @return
*/
@Bean
public OracleKeyGenerator oracleKeyGenerator() {
return new OracleKeyGenerator();
}
}
(2)、拦截器代码:
@Slf4j
@Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})})
public class AlterSessionInterceptor implements Interceptor {
@Override
public Object intercept(Invocation invocation) throws Throwable {
Object[] args = invocation.getArgs();
Connection connection = (Connection) args[0];
if ("Oracle".equalsIgnoreCase(connection.getMetaData().getDatabaseProductName())) {
Statement statement = null;
try {
statement = connection.createStatement();
String locale = RequestHelper.getCurrentLocale();
if ("en_GB".equalsIgnoreCase(locale)) {
statement.execute("ALTER SESSION SET NLS_LANGUAGE=''AMERICAN''");
} else {
statement.execute("ALTER SESSION SET NLS_LANGUAGE=''SIMPLIFIED CHINESE''");
}
} finally {
statement.close();
}
}
return invocation.proceed();
}
@Override
public Object plugin(Object target) {
if (target instanceof StatementHandler) {
return Plugin.wrap(target, this);
}
return target;
}
@Override
public void setProperties(Properties properties) {
// to do nothing
}
三、方案对比
1、在数据源配置,一次性配置,不用修改代码,所有用户都全部看到的错误信息全部都是英文提示
2、在代码进行拦截处理,需要修改代码,可针对不同的用户显示不同语言版本的错误提示,但是每次执行语句时,都须要多执行一句设置语言版本语句,操作繁琐,影响性能
Oracle NLSSORT
今天第一次看到Oracle中的NLSSORT函数,有点意思,可以根据汉字做个性化的排序。
create table test(name varchar2(20));
insert into test values('中国');insert into test values('美国');
insert into test values('日本');
insert into test values('德国');
insert into test values('法国');
insert into test values('英国');
commit;
sql> SELECT * FROM test ORDER BY NLSSORT(name,'NLS_SORT = SCHInesE_PINYIN_M');
NAME
--------------------
德国
法国
美国
日本
英国
中国
sql> SELECT * FROM test ORDER BY NLSSORT(name,'NLS_SORT = SCHInesE_stroke_M');
NAME
--------------------
中国
日本
法国
英国
美国
德国
我们今天的关于ORACLE-如何创建在NLS_COMP =语言且NLS_Sort = Binary_CI时将使用的索引和oracle创建synonym的分享已经告一段落,感谢您的关注,如果您想了解更多关于Insert Unicode Using cx-Oracle and Setting NLS_LANG for Oracle、mtk_gps_sys_gps_mnl_callback、mybatis操作Oracle数据库如何指定NLS_LANGUAGE多语言、Oracle NLSSORT的相关信息,请在本站查询。
本文标签: