ORACLE_LPAD_FUNCTION

本文介绍了 Oracle/PLSQL 中的 LPAD 函数,详细解释了如何使用此函数为字符串左侧填充特定字符,并通过实例展示了不同参数组合下 LPAD 函数的应用效果。

Oracle / PLSQL: LPAD Function

This Oracle tutorial explains how to use the Oracle/PLSQL LPAD function with syntax and examples.

Description

The Oracle/PLSQL LPAD function pads the left-side of a string with a specific set of characters (when string1 is not null).

Syntax

The syntax for the LPAD function in Oracle/PLSQL is:

LPAD( string1, padded_length [, pad_string] )

Parameters or Arguments

string1
The string to pad characters to (the left-hand side).
padded_length
The number of characters to return. If the padded_length is smaller than the original string, the LPAD function will truncate the string to the size of padded_length.
pad_string
Optional. This is the string that will be padded to the left-hand side of string1. If this parameter is omitted, the LPAD function will pad spaces to the left-side of string1.

Returns

The LPAD function returns a string value.

Applies To

The LPAD function can be used in the following versions of Oracle/PLSQL:

  • Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

Example

Let's look at some Oracle LPAD function examples and explore how to use the LPAD function in Oracle/PLSQL.

For example:

 table can use dual example.such as select lpad('tech',7) from dual;

LPAD('tech', 7);
Result: '   tech'

LPAD('tech', 2);
Result: 'te'

LPAD('tech', 8, '0');
Result: '0000tech'

LPAD('tech on the net', 15, 'z');
Result: 'tech on the net'

LPAD('tech on the net', 16, 'z');
Result: 'ztech on the net'

转载于:https://www.cnblogs.com/yjhlsbnf/p/7790069.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值