Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: SQL
Expertise: Beginner
Apr 11, 2017



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Use SUBSTR to Remove the Last Character from any String in Oracle SQL

Let's say you have a set of string values (such as values in a column) and you want to remove the last character. But, the string values are all different lengths. How can you do that?

Use a combination of the LENGTH and SUBSTR functions.

First, use LENGTH to find the length of a string. Then, find use SUBSTR to get the entire string except for the LENGTH minus 1.

SUBSTR(your_column, 0, LENGTH(your_column) - 1)
FROM your_table;

This will remove the last character from your string. It's great for removing trailing slashes or other characters from the end of a string.

Ben Brumm
Thanks for your registration, follow us on our social networks to keep up-to-date