devxlogo

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

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.

SELECTSUBSTR(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.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist