Oracle nvarchar2錯誤
Oracle nvarchar2 錯誤
問題:
使用substr函式擷取指定字串時,取出4位字元 年(例如2019),結果只取出3位(例如201);
問題原因:
字元型別 nvarchar2
解決方案:
透過TRANSLATE函式將 nvarchar2 轉換成 varchar2 。
問題重現:
---1 建立測試資料
create table t1(id number,t_format nvarchar2(100),t_name varchar2(100));
insert into t1 values(1,'abcde2019xxx0707uuu','abcde2019xxx0707uuu');
commit;
---2 透過substr函式擷取年月日
select id,
t_format,
t_name,
length(t_format),
length(t_name),
substr(t_format, 6, 4),
substr(t_format, 13, 4),
substr(t_name, 6, 4),
substr(t_name, 13, 4)
from t1;
select id,
t_format,
t_name,
substr(t_format, 6, 5),
substr(t_format, 13, 5),
substr(t_name, 6, 4),
substr(t_name, 13, 4)
from t1;
---3 透過TRANSLATE函式將 nvarchar2 轉換成 varchar2
select id,
t_format,
t_name,
substr(utl_raw.cast_to_varchar2(utl_raw.cast_to_raw(Translate(t_format USING CHAR_CS))),6,4),
substr(utl_raw.cast_to_varchar2(utl_raw.cast_to_raw(Translate(t_format USING CHAR_CS))),13,4),
substr(t_name, 6, 4),
substr(t_name, 13, 4)
from t1;
NVARCHAR2 Data Type
The NVARCHAR2 data type is a Unicode-only data type. When you create a table with an NVARCHAR2 column, you supply the maximum number of characters it can hold. Oracle subsequently stores each value in the column exactly as you specify it, provided the value does not exceed the maximum length of the column.
The maximum length of the column is determined by the national character set definition. Width specifications of character data type NVARCHAR2 refer to the number of characters. The maximum column size allowed is 4000 bytes.
歡迎關注我的微信公眾號"IT小Chen",共同學習,共同成長!!!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29785807/viewspace-2649779/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORACLE 錯誤Oracle
- ORACLE 異常錯誤 錯誤號大全Oracle
- Oracle 錯誤收集Oracle
- ORACLE錯誤大全Oracle
- EF Oracle:錯誤 175Oracle
- oracle 常見錯誤Oracle
- oracle錯誤小結Oracle
- Oracle安裝錯誤Oracle
- Oracle ASM 配置錯誤OracleASM
- 遇到 ORACLE 錯誤 6550Oracle
- Oracle ORA 錯誤大全Oracle
- oracle 報大小寫錯誤Oracle
- Oracle錯誤號檢索Oracle
- ORACLE tsm 備份錯誤Oracle
- perl連線Oracle錯誤Oracle
- oracle的1788錯誤碼Oracle
- ORACLE 錯誤一覽表Oracle
- oracle錯誤一覽(轉)Oracle
- Oracle ORA-錯誤表Oracle
- Oracle 中varchar2 和nvarchar2區別Oracle
- oracle EBS啟動無錯誤,訪問網頁500錯誤Oracle網頁
- Oracle異常錯誤處理Oracle
- ORACLE 異常錯誤處理Oracle
- oracle dataguard 配置錯誤彙總Oracle
- Oracle之Rman常見錯誤Oracle
- Oracle錯誤處理思路(一)Oracle
- oracle 11g 錯誤收集Oracle
- Oracle中NVARCHAR2與VARCHAR2的區別Oracle
- oracle ora-00054錯誤處理Oracle
- oracle 自帶錯誤提示工具oerrOracle
- oracle 10.2.0.4 的emca配置錯誤Oracle
- 【ORACLE 匯入匯出】exp 錯誤Oracle
- oracle錯誤之ORA-00600Oracle
- Oracle DataGuard Standby database ID mismatch錯誤OracleDatabase
- ORACLE EBS中OAF遮蔽的錯誤Oracle
- oracle日誌錯誤恢復(轉)Oracle
- ORACLE匯入遇到ORACLE錯誤959解決方法Oracle
- oracle ASM錯誤Initializing the Oracle ASMLib driver:[FAILED]OracleASMAI