lpad( string, padded_length, [ pad_string ] )
聽
銆€銆€string
銆€銆€鍑嗗琚~鍏呯殑瀛楃涓诧紱
聽
銆€銆€padded_length
銆€銆€濉厖涔嬪悗鐨勫瓧绗︿覆闀垮害(涓嶇鏄埅鍙栬繕鏄ˉ鍏咃紝鍑芥暟return鐨勫瓧绗﹂暱搴?padded_length)锛屼篃灏辨槸璇ュ嚱鏁拌繑鍥炵殑瀛楃涓查暱搴︼紝濡傛灉杩欎釜鏁伴噺姣斿師瀛楃涓茬殑闀垮害瑕佺煭锛坧added_length<length(string)锛夛紝lpad鍑芥暟灏嗕細鎶婂瓧绗︿覆鎴彇鎴愪粠宸﹀埌鍙崇殑n涓瓧绗? 濡傛灉杩欎釜鏁伴噺姣斿師鏉ョ殑瀛楃涓查暱搴﹁闀匡紙padded_length>length(string)锛夛紝鍒欏湪宸﹁竟琛ヤ笂绌烘牸
銆€銆€pad_string
聽
銆€銆€濉厖瀛楃涓诧紝鏄釜鍙€夊弬鏁帮紝杩欎釜瀛楃涓叉槸瑕佺矘璐村埌string鐨勫乏杈癸紝濡傛灉杩欎釜鍙傛暟鏈啓锛宭pad鍑芥暟灏嗕細鍦╯tring鐨勫乏杈圭矘璐寸┖鏍笺€?/p>
銆€銆€绀轰緥1锛?/p>
聽
銆€銆€SQL> select lpad('abcde',10,'x') from dual;
銆€銆€LPAD('ABCDE',10,'X')
銆€銆€--------------------
銆€銆€xxxxxabcde
銆€銆€绀轰緥2锛?/p>
聽
銆€銆€SQL> select lpad('abcde',10,'oq') from dual;
銆€銆€LPAD('ABCDE',10,'OQ')
銆€銆€---------------------
銆€銆€oqoqoabcde 锛堟敞鎰忓浣曟樉绀虹殑锛?/p>
銆€銆€绀轰緥3锛?/p>
聽
銆€銆€SQL> select lpad('abcde',2) from dual;
銆€銆€LPAD('ABCDE',2)
銆€銆€---------------
銆€銆€ab
銆€銆€~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
銆€銆€涓巐pad鍑芥暟瀵瑰簲鐨勬槸rpad鍑芥暟锛?/p>
銆€銆€rpad鍑芥暟浠庡彸杈瑰瀛楃涓蹭娇鐢ㄦ寚瀹氱殑瀛楃杩涜濉厖锛岃娉曟牸寮忎笌lpad鏍煎紡鐩稿悓锛?/p>
銆€銆€rpad(string,padded_length,[pad_string])
銆€銆€string
銆€銆€琚~鍏呯殑瀛楃涓?/p>
銆€銆€padded_length
銆€銆€瀛楃鐨勯暱搴︼紝鏄繑鍥炵殑瀛楃涓茬殑鏁伴噺锛屽鏋滆繖涓暟閲忔瘮鍘熷瓧绗︿覆鐨勯暱搴﹁鐭紝rpad鍑芥暟灏嗕細鎶婂瓧绗︿覆鎴彇鎴愪粠宸﹀埌鍙崇殑n涓瓧绗︼紙閮芥槸浠庡乏鍒板彸锛? 濡傛灉杩欎釜鏁伴噺姣斿師瀛楃涓茬殑闀垮害瑕侀暱锛屽垯鍦ㄥ彸杈硅ˉ涓婄┖鏍?/p>
銆€銆€pad_string
銆€銆€鏄釜鍙€夊弬鏁帮紝杩欎釜瀛楃涓叉槸瑕佺矘璐村埌string鐨勫彸杈癸紝濡傛灉杩欎釜鍙傛暟鏈啓锛宭pad鍑芥暟灏嗕細鍦╯tring鐨勫彸杈圭矘璐寸┖鏍笺€?/p>
銆€銆€渚嬪锛?/p>
銆€銆€rpad('tech', 7); 灏嗚繑鍥? tech '
銆€銆€rpad('tech', 2); 灏嗚繑鍥?te'
銆€銆€rpad('tech', 8, '0'); 灏嗚繑鍥?tech0000'
銆€銆€rpad('tech on the net', 15, 'z'); 灏嗚繑鍥?'tech on the net'
銆€銆€rpad('tech on the net', 16, 'z'); 灏嗚繑鍥?'tech on the netz'