Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Functions for Manipulating Data in PostgreSQL

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

-- Concatenate the padded first_name and last_name 
SELECT 
	___(___, LENGTH(first_name)+1) || ___ AS full_name
FROM customer;
Code bewerken en uitvoeren