NVARCHR2怎么转换成VARCHAR2

如题所述

自动转换的,但是NVARCHAR2优先级高点,所以遇到where varchar2 =nvarchar2的,会将varchar2自动转为nvarchar2

SQL> drop table t;

Table dropped

SQL> create table t(name nvarchar2(100));

Table created

SQL> insert into t values('abc');

1 row inserted

SQL> explain plan for
2 select * from t where name='abc';

Explained

SQL> select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 1601196873
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 102 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| T | 1 | 102 | 3 (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("NAME"=U'abc')
Note
-----
- dynamic sampling used for this statement (level=2)

17 rows selected

SQL> drop table t;

Table dropped

SQL> create table t(name varchar2(100));

Table created

SQL> insert into t values('abc');

1 row inserted

SQL> select * from t where name=u'abc';

NAME
--------------------------------------------------------------------------------
abc

SQL> explain plan for
2 select * from t where name=u'abc';

Explained

SQL> select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 1601196873
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 52 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| T | 1 | 52 | 3 (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(SYS_OP_C2C("NAME")=U'abc')
Note
-----
- dynamic sampling used for this statement (level=2)

17 rows selected
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网