oracle 中的Ipad()函数

时间:2022-03-30 01:10:40

本文基于转载:

lpad函数从左边对字符串使用指定的字符进行填充。lpad意思是从左边填充的意思。

  语法格式如下:

lpad( string, padded_length, [ pad_string ] );

 string :准备被填充的字符串;

  padded_length:填充之后的字符串长度,也就是该函数返回的字符串长度,如果这个数量比原字符串的长度要短,lpad函数将会把字符串截取成从左到右的n个字符;

pad_string:填充字符串,是个可选参数,这个字符串是要粘贴到string的左边,如果这个参数未写,lpad函数将会在string的左边粘贴空格。

示例1:

   select lpad('abcde',10,'x') from dual;

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPYAAAB0CAIAAAA5CFhMAAAHa0lEQVR4nO2dTZKjOBBGdXS2FVHb2ns/Mas5QHnJrk/Aai6gsA9AL2RjWT+pVCKMSL4XxDQji5SQnhNB0V1m7o+v758/HXC/37++f76+f+73ew89sUCE2dvnBE4sbNiabD0qDkBDoDhQDhQHynko/s+//2HDpnJ7Kb7f1wyADYHiQDlnUdyYYZ5n88Fbj+3a4kSO67gROCFCxc0wuK19h9ZFTh67zG5RDmMq1KQrM+ME1VxM+liZ4jPb8g0n1xjDHl/zZG2j7g9ZFpeNAueoNeMbHMv3u6oaXZnfll8zt18bmfziFQZ2C7PfO1CnLBQvH1t7gW6iuCwCR/HVzUFxV/q8VPknHF+8EkuCVB2/kHkRjNvNRSbaehQWJzVKpfFSIS7MldSyXvGlXU4H6NEIhjre8aslDyGbfi084h2/TnBU1Skk2nV/xIqH9bxTylWL63COSnerPnKyrbk4qWarHSZNsviiOKNmXRYn8tpif/DfTLtGsBPsy8guVJJf3LgwPiT4iieabKG43xxRZ2Zn8Sprk3U4d4rJ1ov7tXHIatWK5yo0V3x+z/TxpzKyij8+rpGVGI5iITPyvlmcc1Qt/WfxXIVjZ3FiLe4vzug6uZKlMN2hVGQiCGddWLTcT8C1a/E4kecbinRhLfFZVyF/h9+BsEJqLZ60nBA937oJkjRdEsA/i7Bd90fnP/rhJP5ChMpx2QJZH1r1vI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VS8nGKpCxFeJm7Icw5pGwAI2XKDMk9B/ljaRy+GO+xk+kJKX9RIqVJs/UPCluqm9+f3K4wTlxKmRa5aszmUhGEOYeUDTjt4fm1SObA9xFmCVI24A6/ZmzyrRBmaTQpJ9A/o0kppO0+m+h/YQU7eT6fV0+hnszpO3XScVL+3whI2ZzBpSS9hJTKGV/K2Ms6KY0xFVK6CZyRjIG4hZSBlxVSuiB1lRJSlnIXKX0vz6yUK6Qs50ZSbl4eLWVwyt62flpeeudGUp5TKbcfmRXAcxcpz7zRCUojpCzlFlLab1AplTO+lDai+u6b9JKplO4jXFOWMriUsZHVlZLx9dIkDMjIUqaAlMoZSsoL3mmZJiP4S6CglKvVqqfyLSEAjgNSAnVASqAOSAnU8Q9USB4mpAv+wgAAAABJRU5ErkJggg==" alt="" />

 与lpad函数对应的是rpad函数,rpad函数从右边对字符串使用指定的字符进行填充,语法格式与lpad格式相同。