ComeçarComece de graça

Padding

Padding strings is useful in many real-world situations. Earlier in this course, we learned about string concatenation and how to combine the customer's first and last name separated by a single blank space and also combined the customer's full name with their email address.

The padding functions that we learned about in the video are an alternative approach to do this task. To use this approach, you will need to combine and nest functions to determine the length of a string to produce the desired result. Remember when calculating the length of a string you often need to adjust the integer returned to get the proper length or position of a string.

Let's revisit the string concatenation exercise but use padding functions.

Este exercício faz parte do curso

Functions for Manipulating Data in PostgreSQL

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

-- Concatenate the padded first_name and last_name 
SELECT 
	___(___, LENGTH(first_name)+1) || ___ AS full_name
FROM customer;
Editar e executar o código