{"rsdb":{"rid":"314253","subhead":"","postdate":"0","aid":"227495","fid":"57","uid":"1","topic":"1","content":"

\u95ee\u9898\uff1a<\/strong><\/p>

\u4f7f\u7528  substr\u51fd\u6570\u622a\u53d6\u6307\u5b9a\u5b57\u7b26\u4e32\u65f6\uff0c\u53d6\u51fa4\u4f4d\u5b57\u7b26 \u5e74(\u4f8b\u59822019),\u7ed3\u679c\u53ea\u53d6\u51fa3\u4f4d(\u4f8b\u5982201)\uff1b <\/p>

\u95ee\u9898\u539f\u56e0\uff1a   <\/strong><\/p>

\u5b57\u7b26\u7c7b\u578b  nvarchar2 <\/p>

\u89e3\u51b3\u65b9\u6848\uff1a<\/strong>   <\/p>

\u901a\u8fc7  TRANSLATE\u51fd\u6570\u5c06  nvarchar2  \u8f6c\u6362\u6210  varchar2  \u3002  <\/p>

\u95ee\u9898\u91cd\u73b0\uff1a   <\/strong><\/p>

---1 \u521b\u5efa\u6d4b\u8bd5\u6570\u636e <\/p>

create table t1(id number,t_format nvarchar2(100),t_name varchar2(100)); <\/p>

 insert into t1 values(1,'abcde2019xxx0707uuu','abcde2019xxx0707uuu'); <\/p>

 commit; <\/p>

---2 \u901a\u8fc7substr\u51fd\u6570\u622a\u53d6\u5e74\u6708\u65e5 <\/p>

select id, <\/p>

        t_format, <\/p>

        t_name, <\/p>

        length(t_format), <\/p>

        length(t_name), <\/p>

        substr(t_format, 6, 4), <\/p>

        substr(t_format, 13, 4), <\/p>

        substr(t_name, 6, 4), <\/p>

        substr(t_name, 13, 4) <\/p>

  from t1; <\/p>

\"\"<\/p>

 select id, <\/p>

        t_format, <\/p>

        t_name, <\/p>

        substr(t_format, 6, 5), <\/p>

        substr(t_format, 13, 5), <\/p>

        substr(t_name, 6, 4), <\/p>

        substr(t_name, 13, 4) <\/p>

  from t1; <\/p>

\"\"<\/p>

---3  \u901a\u8fc7  TRANSLATE\u51fd\u6570\u5c06  nvarchar2  \u8f6c\u6362\u6210  varchar2 <\/p>

 select id, <\/p>

        t_format, <\/p>

        t_name, <\/p>

        substr(utl_raw.cast_to_varchar2(utl_raw.cast_to_raw(Translate(t_format USING CHAR_CS))),6,4), <\/p>

        substr(utl_raw.cast_to_varchar2(utl_raw.cast_to_raw(Translate(t_format USING CHAR_CS))),13,4), <\/p>

        substr(t_name, 6, 4), <\/p>

        substr(t_name, 13, 4) <\/p>

from t1; <\/p>

\"\"<\/p>

https:\/\/docs.oracle.com\/cd\/E11882_01\/server.112\/e41084\/sql_elements001.htm#SQLRF30020<\/a>   <\/p>

NVARCHAR2 Data Type  <\/p>

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.<\/p>","orderid":"0","title":"Oracle nvarchar2 \u9519\u8bef\u89e3\u51b3\u65b9\u6848","smalltitle":"","mid":"0","fname":"\u6570\u636e\u5e93\u7f16\u7a0b","special_id":"0","bak_id":"0","info":"0","hits":"77","pages":"1","comments":"0","posttime":"2019-07-10 20:11:26","list":"1562760686","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"Oracle<\/A> nvarchar2<\/A> \u9519\u8bef<\/A> \u89e3\u51b3\u65b9\u6848<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"47.106.78.186","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"Oracle nvarchar2 \u9519\u8bef\u89e3\u51b3\u65b9\u6848","lastview":"1712971754","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}