Created
March 16, 2018 10:50
-
-
Save barsbek/0f9e4a91a6abebd2d5352a791bd66c8a to your computer and use it in GitHub Desktop.
postgresql: fill up or truncate the string to length
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rpad(string text, length int [, fill text]) | |
fill is space by default | |
select rpad('hello', 10, 'w') -- hellowwwww | |
select lpad('hello', 10, 'p') -- ppppphello | |
select lpad('hello', 10) -- ' hello' | |
select rpad('hello', 4) -- hell | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment