Beginner

206. Character Length

Understand how SQL determines the number of characters in text values.

📘 Lesson 206 of 728 ⏱ 8 min 🎯 Beginner

Character-length functions return the number of characters contained in a text value. The exact function name can differ between database systems.

Character length checks help identify invalid, incomplete, or unusually long values.

Check the length of customer names.

SQL
SELECT
    CustomerName,
    LENGTH(CustomerName) AS NameLength
FROM Customers;

Character length is useful for validation, data profiling, cleansing, and checking business field limits.

  • Character length measures text size.
  • Function names vary across databases.
  • It can be used for validation.
  • It can be used in WHERE conditions.
  • It helps identify unusual data.
Why calculate text length?

Text length can help validate data and identify values that are unusually short or long.

Is the length function named the same everywhere?

No. Different database systems may use functions such as LENGTH or LEN.

Have you finished this lesson?

Introduction to SQL – All Lessons