Aan de slagGa gratis aan de slag

Replacing string data

Sometimes you will need to make sure that the data you are extracting does not contain any whitespace. There are many different approaches you can take to cleanse and prepare your data for these situations. A common technique is to replace any whitespace with an underscore.

In this example, we are going to practice finding and replacing whitespace characters in the title column of the film table using the REPLACE() function.

Deze oefening maakt deel uit van de cursus

Functions for Manipulating Data in PostgreSQL

Cursus bekijken

Oefeninstructies

  • Replace all whitespace with an underscore.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

SELECT 
  -- Replace whitespace in the film title with an underscore
  ___(___, ___, ___) AS title
FROM film; 
Code bewerken en uitvoeren