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

Three key aspects of being a threat hunter  

Three key aspects of being a threat hunter  

In today’s digital landscape, the role of a threat hunter has become indispensable. As cyber threats grow increasingly sophisticated, the need for professionals who can…

5 minute read

Fax and figures – automate your fax processes for maximum productivity

Fax and figures – automate your fax processes for maximum productivity

Manual fax processing isn’t scalable

4 minute read

Insights on AI and ISO 20022: OpenText helps shape the narrative at the Payments Canada Summit

Insights on AI and ISO 20022: OpenText helps shape the narrative at the Payments Canada Summit

The 2024 Payments Canada Summit recently concluded, bringing together industry leaders, innovators, and key stakeholders to discuss the most recent trends and insights in payments….

5 minute read

Stay in the loop!

Get our most popular content delivered monthly to your inbox.

Sign up