Home / Learn Secure SQL / String Functions

String Functions

LENGTH, SUBSTR, UPPER/LOWER, TRIM, and concatenation.

Bottom lineLENGTH, SUBSTR, UPPER/LOWER, TRIM, and concatenation.

Breaking it down

A few string functionsUPPER/LOWERTRIMSUBSTRconcatenation
A few string functions

The basic idea

Databases provide functions to inspect and transform text: measure length, extract part of a string, change case, trim whitespace, join strings together.

Why this comes up

Knowing these lets you do simple text handling in SQL rather than pulling everything back to re-process in application code, and matters when you later see how some of these same functions are abused when a query is built unsafely.

The mechanics

Use the function names for your specific dialect; behaviour for NULL input usually propagates NULL.

Where it is used

  • Web application code review
  • Backend development
  • Database administration
String functionsSQL: edit and run

Each function transforms the text in a simple, predictable way.

Quick check

1. Concatenation in standard SQL uses...