Insert Spaces Into a Character String: Quick Tip

In many SQL relational database you will have to use the RPAD function to insert spaces into a character string. That also works in Vertica….

OpenText profile picture
OpenText

November 20, 20181 minute read

Rear view of two partially unrecognizable men sitting in front of a computer. One of them is pointing at a screen where are several lines of computer code.

In many SQL relational database you will have to use the RPAD function to insert spaces into a character string. That also works in Vertica. However, for a more robust solution, Vertica provides the built-in function SPACE which returns the specified number of blank spaces.

Example:

dbadmin=> SELECT 'ABC' || RPAD(' ', 10, ' ') || 'DEF' "Insert 10 spaces!";
Insert 10 spaces!
-------------------
ABC DEF
(1 row)

dbadmin=> SELECT ‘ABC’ || SPACE(10) || ‘DEF’ “Insert 10 spaces!”;
Insert 10 spaces!
——————-
ABC DEF
(1 row)

dbadmin=> SELECT ‘My girlfriend broke up with me because she said she needed ‘ || SPACE(10) || ‘!?!?’ AS “?”;
?
—————————————————————————
My girlfriend broke up with me because she said she needed !?!?
(1 row)

Have fun!

Share this post

Share this post to x. Share to linkedin. Mail to
OpenText avatar image

OpenText

OpenText, The Information Company, enables organizations to gain insight through market-leading information management solutions, powered by OpenText Cloud Editions.

See all posts

More from the author

Manutan combines digital services with the human touch to delight customers

Manutan combines digital services with the human touch to delight customers

At Manutan, we equip businesses and communities with the products and services they require to succeed. Headquartered in France, our company has three divisions, serving…

4 minute read

Reaching new markets in Europe and beyond

Reaching new markets in Europe and beyond

How information management specialists at One Fox slashed time to market for innovative products with OpenText Cloud Platform Services At One Fox, we’ve driven some…

4 minute read

SoluSoft helps government agencies tackle fraud faster

SoluSoft helps government agencies tackle fraud faster

Fraud, in all its forms, is a pervasive problem, spanning industries and preying on vulnerabilities in federal and state government systems. Each year in the…

3 minute read

Stay in the loop!

Get our most popular content delivered monthly to your inbox.