RPAD
All functions > STRING > RPAD
Returns the string padded on the right to a specified length with a padding string.
Signatures
Returns: String padded on the right to the specified length
RPAD(string: VARCHAR, length: BIGINT, padding: VARCHAR) → VARCHAR sql
| Parameter | Type | Required | Description |
|---|---|---|---|
string | VARCHAR | Yes | String to pad |
length | BIGINT | Yes | Target length for the result |
padding | VARCHAR | Yes | String to use for padding |
Notes
- If string is already longer than length, it is truncated from the right
- Padding string is repeated as needed
- If padding string is longer than needed, only part of it is used
Examples
FeatureQL
SELECT
f1 := RPAD('hello', 10, '-'), -- Pad with dashes
f2 := RPAD('123', 7, '0'), -- Zero padding
f3 := RPAD('AB', 6, 'XY'), -- Multi-character padding
f4 := RPAD('hello', 3, '-'), -- Truncation when too long
f5 := RPAD('test', 4, ' ') -- No padding needed
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR | f4 VARCHAR | f5 VARCHAR |
|---|---|---|---|---|
| hello----- | 1230000 | ABXYXY | hel | test |
On this page