ComeçarComece de graça

Determining the length of strings

Determining the number of characters in a string is something that you will use frequently when working with data in a SQL database. Many situations will require you to find the length of a string stored in your database. For example, you may need to limit the number of characters that are displayed in an application or you may need to ensure that a column in your dataset contains values that are all the same length. In this example, we are going to determine the length of the description column in the film table of the DVD Rental database.

Este exercício faz parte do curso

Functions for Manipulating Data in PostgreSQL

Ver curso

Instruções do exercício

  • Select the title and description columns from the film table.
  • Find the number of characters in the description column with the alias desc_len.

Exercício interativo prático

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

SELECT 
  -- Select the title and description columns
  ___,
  ___,
  -- Determine the length of the description column
  ___(___) AS ___
FROM film;
Editar e executar o código